"Main" link on menu point to template blog site

Hej,

I have a blog template where in the menu there is:

1. Main Page Link

2. Page

3 . cpt-archive

4. page

When creating a new blog I get menu:

1. Main Page Link –> Points to the template blog

2. Page — OK

3 . cpt-archive –> Points to the template cpt-archive link

4. page — OK

What to do?

Thanks,

Koff

  • koff
    • Site Builder, Child of Zeus

    Hej!

    I add the followin code to solve this:

    add_filter( 'blog_templates-process_row', 'filter_url_new_template_blog',10,3);

    function filter_url_new_template_blog( $row , $table , $templated_blog_id) {

    $templateurl = get_site_url( $templated_blog_id);
    $newurl = get_site_url();
    foreach ($row as $key=>$value) {
    $newrow[$key] = str_replace( $templateurl ,$newurl, $value );

    }
    return $newrow;
    }

    And on blog_templates.php I:

    1. added template id to the filter.

    2. Fix the code to use the $proccess after the filter instead of $row

    $process = apply_filters('blog_templates-process_row', $row, $table,$templated_blog_id);
    if (!$process) continue;

    $wpdb->insert($wpdb->$table,$process);

    This fixes ALL links from the template blog to the new blog ( might be unexpected result).

    Can you approve thats the way to do it?

    Thanks,

    Koff

  • aecnu
    • WP Unicorn

    Greetings Koff,

    I do indeed have the lead developer flagged for input into this ticket, but I was curious to know why you gave the answer cause it doesn’t matter :slight_smile: to my question you mentioned in your fix I add the followin code to solve this: but you did not mention where you added this code?

    Why doesn’t it matter?

    Cheers, Joe

  • koff
    • Site Builder, Child of Zeus

    About the small bug fix:

    its on blog_templates.php.

    About the added code:

    The added code is adding a filter.

    It dosen’t mater where you add the filter as long as its added.

    I added it as a mu-plugin. called ( my bug fixes).

    I do think that the developer of the plugin should consider of adding such a filter built in the code, cause for my opinion at the moment this doesn’t function as the user would expect it too.

    Koff

  • aecnu
    • WP Unicorn

    Greetings Koff,

    Thank you for your feedback and instructions, it is greatly appreciated.

    While we are waiting lead developer arrival on this ticket, could you please give a small recap of the issue as it is at this moment?

    Thanks again for your input and some rep points sent your way for your post.

    Cheers, Joe

  • koff
    • Site Builder, Child of Zeus

    Hi,

    Two issues:

    Issue 1: when using blog templates the script copies the data from the template blog to the newly created blog. This means that Inside links like nav_menu are copied with the domain of the template, so The newly create blog points to the template blog.

    I guess this is not the expected result, and this should maybe be approached by the developer of the plugin.

    The way so solve this is to use the filter “blog_templates-process_row'” as instructed above.

    BUT there comes the second issue, (BUG) the filter has no affect on the code.

    This MUST be fixed as instructed above for the filter to work.

    Koff

  • aecnu
    • WP Unicorn

    Greetings Koff,

    It appears this particular topic is now resolved/closed, if you need any further assistance please let us know.

    If it wasn’t resolved, or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the ‘Mark as Not Resolved (re-open)’ box below the post area (or else we’ll miss it!)

    Thank you for being a WPMU Dev member!

    Cheers, Joe :slight_smile:

  • aecnu
    • WP Unicorn

    Greetings Koff,

    I believe we are having a communication problem here.

    I thought you already resolved the issue on your end … lol

    I am not a coder, I can code some but not much.

    The earlier ping for the lead developer in here still stands :slight_smile:

    I develop a lot, but usually use the tools given me using them in the manner of there intended purpose and the parameters provided within – therefore I have very few issues.

    You are already above me in coding from what I can see.

    Even if I could code this, I do not have the authority to apply it to the plugin stored on WPMU Dev for the good of the many rather then the benefit of the few or the one, therefore the lead developers attention needs to be brought into the picture.

    My job on WPMU Dev is very specific, offer any solutions that I can to resolve a members problem that is legal i.e. plugins, instructions on using our plugins etc.

    And as the WPMU Dev lead developer stated our mission very plainly:

    The support we provide here is how to use the current features of our products and bug fixing, teaching someone to code PHP is a bit beyond that scope.

    Reference: https://premium.wpmudev.org/forums/topic/export-order-details#post-194890

    I will indeed help anytime I can, if I can, but if I cannot …. well then I cannot.

    As you have seen in other tickets I have replied to, I am indeed doing my job exactly within the parameters I am afforded and my skill level and authorization.

    Ve the lead devloper of the New Blog Templates plugin is indeed flagged to respond to this ticket.

    Cheers, Joe

  • koff
    • Site Builder, Child of Zeus

    Hej,

    by “you” I mean wpmudev team.

    As I said there are two issues here.

    1. Small bug fix, that is must.

    2. A decision of what to do with URLs when copying blog.

    I excepted “You” to fix the bug, and have an answer about the second question.

    This issue is now almost two month old.

    Thanks,

    Koff

  • aecnu
    • WP Unicorn

    Greetings Koff,

    I knew we were having a communication problem here …. lol

    Thank you for your clarification above.

    I realize the aging of the ticket but I have done everything I can to help and that is the absolute truth.

    Once I have called in the lead developer on a ticket, my responsibility has ended, though I do churn the tickets keeping them alive so they do not fall into the ticket system abyss where they are no longer in view of anybody and may go permanently unaddressed, and not that this is part of my mandate, I just do it to help our members and to try to get the issues addressed by the lead developer or the person responsible for resolving the issue.

    Thank you again for your clarification, it is appreciated and I hope you understand that we on the support team do honestly try to help the best that we can and then when we get to the end of that road or our capabilities, it becomes the Developer teams responsibility to resolve what we cannot if possible. They are all coders.

    Thank you for your understanding and appreciate that we have reached the limit of my personal skills regarding coding. But if you want to dig into servers, networks, or linux I am in and make most folks eyes glaze over with my knowledge and talents thereof.

    Cheers, Joe

  • Vladislav
    • Dead Eye Dev

    Hello,

    The filter in question was originally intended to blacklist a whole row of options – but I agree that it can double as a preprocessing filter too, and that it’s even more useful in doubled up role like that. In the latest plugin release (v1.6.1, just released), that’s how the filter behaves. However, the release doesn’t include the custom code you have hooked up to it – you code should still work for you without any changes though.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.