• Resolved Enrique J. Ros

    (@enriquejros)


    Hello

    I’ve created a custom post type for a customer who’s using Virtue Premium, but it’s not showing the sidebar in the single cpt page (everything’s ok in the archive page).

    I’ve created a template named content-single[name of cpt].php under templates copied from content-single.php and also created single-[name of cpt].php to load it. Even also tried with a global $virtue_premium and setting $display_sidebar=true at the begining of the template, but didn’t work.

    How can I get it to show the sidebar in the single cpt page? Thanks in advance.

Viewing 15 replies - 1 through 15 (of 27 total)
  • hannah

    (@hannahritner)

    Hi,
    Are you using a child theme? Can you post a link to your site?
    If you’re using Virtue Premium you can use the premium forums – https://www.kadencethemes.com/support-forums/forum/virtue-theme/

    Hannah

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Hi Hannah
    Thanks for your kind response. No, I’m not using a child theme, it’s a staging server and I not going to do any changes in the theme (I added those templates just trying, but actually shouldn’t be necessary, I already removed them).

    The source code shows the sidebar section, but it’s empty. If I switch the theme to TwentyTwelve, the sidebar is shown correctly.

    Link to site: https://espacioulises.tk/
    CPT archive: https://espacioulises.tk/relatos/
    Single CPT: https://espacioulises.tk/relatos/ulises-en-el-festival-de-cannes-relato-vidas-de-cine-de-patxi-hinojosa-lujan/
    Single regular post: https://espacioulises.tk/resena-putas-asesinas-de-roberto-bolano/

    Many thanks again
    Enrique

    hannah

    (@hannahritner)

    Which sidebar are you enabling in your single cpt pages? I’m seeing a sidebar, but without content. Have you added content from Appearance > Widgets?

    Hannah

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Many thanks again, Hannah
    That may be the problem, I haven’t done anything special to enable a sidebar with the cpt page. I’ve search in the options of the theme but didn’t find anything. There are two sidebars with widgets inside but, how should I enable a sidebar to be shown in that content page?

    hannah

    (@hannahritner)

    You should see an option to select a sidebar within the post edit page under Post Options. Let me know if you’re not seeing it there.

    Hannah

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Hi Hannah
    Now I see what the problem is. The theme enables those options via custom fields, so they only appear in the post types created by the theme. Is there a hook I can use in the API of the framework to enable those options in my cpt? perhaps by using add_post_type_support?

    Many thanks again
    Enrique

    Please use the premium support forms.

    On those forums please clarify if you want to just add a sidebar to the custom post type of if you want to add controls to change on a post by post level whether or not you want a sidebar.

    Ben
    Kadence Themes

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Hi Ben, thanks for your response

    I don’t have access to the premium support forums, I didn’t buy the theme, my client did (I can tell you the activation key by email if necessary).

    I just want my cpt to show the same sidebar as the regular posts do in is_singular

    Thanks again. Best regards.
    Enrique

    add_filter('kadence_display_sidebar', 'custompost_sidebar');
    function custompost_sidebar($sidebar) {
      if (is_singular('custom_post_type')) {
        return true;
      }
      return $sidebar;
    }

    You can use a function like that in a child theme just make sure you change ‘custom_post_type’ with your post type.

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Hi Ben

    Thanks for your kind help, but that didn’t work. I changed the code to:

    add_filter('kadence_display_sidebar', 'custompost_sidebar');
    function custompost_sidebar($sidebar) {
      if (is_singular('post')) {
        return false;
      }
      return $sidebar;
    }

    And regular posts changed to a full-width layout, so I guess the hook kadence_display_sidebar sets the layout. But, as Hannah noticed, the sidebar is there in is_singular(‘my-cpt’), so the layout is content-sidebar, but it’s empty: https://espacioulises.tk/relatos/ulises-en-el-festival-de-cannes-relato-vidas-de-cine-de-patxi-hinojosa-lujan/

    If it helps, $sidebar is getting a ‘1’ (I think that means the layout is set as content-sidebar)

    Many thanks again. Best regards
    Enrique

    Hey,
    I’m confused. why would you be changing the layout for single posts? I thought you wanted to control a custom post type?

    ‘post’ is the default post type in wordpress.

    Please explain more what it is you are trying to do? Are you wanting to have a sidebar or not? On what custom post type?

    And what sidebar do you want to show?

    Ben

    Thread Starter Enrique J. Ros

    (@enriquejros)

    No, I don’t want to change the layout for single posts. Ok, let’s start from the very beginning.

    I did a custom post type, and it’s showing an empty sidebar in the is_singular view, as you can see here: https://espacioulises.tk/relatos/ulises-en-el-festival-de-cannes-relato-vidas-de-cine-de-patxi-hinojosa-lujan/

    I just want your theme to display there the same sidebar shown in single posts.

    Enrique

    Ok, lets say the slug of this custom post type is “recipe” for example. Here is what you can add to your child theme assuming you are using the same style of template as the rest of the theme.

    add_filter('kadence_display_sidebar', 'custompost_sidebar');
    function custompost_sidebar($sidebar) {
      if (is_singular('recipe')) {
        return true;
      }
      return $sidebar;
    }
    add_filter('kadence_display_sidebar', 'custompost_sidebar_id');
    function custompost_sidebar_id($sidebar) {
      if(is_singular( 'recipe' )) {
          $sidebar = 'sidebar-primary';
      }
      return $sidebar;
    }

    Ben

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Hi Ben

    After doing lots of tests, I realized that it was caused by a plugin used to switch previously published posts to the new cpt (Post Type Switcher). For some reason, after using the plugin to switch the post type, the cpt no longer shows the sidebar (although it does with other themes).

    I don’t know the exact cause yet, but I don’t think I get to ever know it: I’ll just look for an alternate way to switch the post type ?? I want to thank you and Hannah very much for your valuable help and your patience.

    Many thanks. Best regards.

    Thread Starter Enrique J. Ros

    (@enriquejros)

    Here again ??

    Is the Kadence adding any meta key to postmeta (or any other table in the database) that may be causing that? I still need to convert those post to cpt and the problem is not caused by the plugin, but by the conversion itself (no matter the way it’s done).

    Regards.

Viewing 15 replies - 1 through 15 (of 27 total)
  • The topic ‘Single custom post type template not showing sidebar in Virtue Premium’ is closed to new replies.