New Blog Templates - having two different tempaltes set as default

I have a strange issue going on that I can not figure out.

I changed the color of the border around the templates when selected or set default to make it work better on my theme. After doing so I found that I have two templates that have the class "blog_template-default_item" on them.

To help debug I added some echo's on a few lines on the blogtemplates.php to help figure out why.

I have changed the default template to other templates, and remove the default template option from all.

In this block. if I have the 1st template set as default it triggers the if statement, the 3rd template triggers the else.
if ( $selected == $tkey ) {
$default = "blog_template-default_item";
}
else {
$default = @$options['default'] == $tkey ? "blog_template-default_item" : "";
}

When I remove the default templates from all of them, the 1st one is still highlighted on page load. If I pick a different category then it will show none selected like it should on page load.

If I set template 2, 3, 4 to default, the 1st one is still highlighted on page load. If I pick a different category.

Then set template1 back to default I get the 1st and 3rd highlighted.

I downgraded to pervious version but see the same thing. then took it back to the current version.

  • Nastia

    Hello @jroe1

    I trust you are doing well today!

    Would you please run a quick check for a conflict with a plugin and theme?

    Deactivate all other plugins, switch to a default WordPress theme and test again. If the issue is gone, please activate one plugin at the time to find out which one is causing this conflict.

    Please follow the flowchart from our manual:
    https://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/

    Do you use any cache plugins? Please clear the website's cache and test again?

    Also, would you please grant support access from your Dashboard > WPMU DEV > Support so that I can check?

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Please advise,

    Cheers,
    Nastia

  • James Roe

    ok, started with theme 1st, most plugins are from wpmudev.

    Switching it to twentysixteen, the issue goes away.

    Digging into my child theme (Customizr Theme) I found where I am having the issue.
    Using some code I found in the forums here, I wanted to remove the "All" button from the Select A Template area.

    add_filter( 'nbt_selection_toolbar_tabs', 'remove_all_tab_theme_selection' );
    function remove_all_tab_theme_selection($tabs ) {
    unset( $tabs[0] );
    return $tabs;
    }
    /* Set Default Category as default */
    add_filter( 'nbt_selection_toolbar_default_tab', 'set_default_tab_theme_selection' );
    function set_default_tab_theme_selection( $default_tab ) {
    return 1;
    }

    I just made a child theme for twentysixteen with no css and just these two statements. I get the 1st and 3rd template with a border around them. Changed to Return 2, same thing.

    It seems like that is when it happens. But when I click on the category its ajax loading properly. It is just how it loads when I 1st come to the page.

    Also granted access to the site.

    Thanks

  • Panos

    Hello @jroe1,
    Hope you are having a nice today!

    I see that the plugin provides a filter to override the default category. Perhaps something might be wrong with the numbering. Well,to find out, could you please edit file "wp-content/plugins/blogtemplates/blogtemplatesfiles/blog_templates_theme_selection_toolbar.php" and execute a var_dump( $tabs ) or print_r( $tabs ) after line 39?
    While you are in the file you could also do the same for $default_tab and see what it returns.

    You can run these with and without the filters you have pasted to see if there is any difference there.

    Please post back the results, so we can figure out if the id's are included or not.

    Looking forward to your reply!

    Kind regards,
    Panos

  • Panos

    Hey James,

    Thanks for the feedback! They seem to be correct and they don't explain the issue. In my testing installation this works properly. For me, without adding the filters code, the "All" is visible but none of the templates is selected. When I insert the filter though the "All" is removed and the first (or whatever number I choose) appears to be selected.

    I have attached a plugin which does the exact same thing provided by Ignacio at this thread https://premium.wpmudev.org/forums/topic/sorting-or-removing-all-option-from-blog-templates. It's worth the try!

    If that doesn't fix this issue let me know so I inform the developer.

    Cheers,
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.