Support » Theme: Virtue » Single custom post type template not showing sidebar in Virtue Premium

  • Resolved Enrique J. Ros



    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 12 replies - 16 through 27 (of 27 total)
  • I don’t understand what your asking. If your using a custom post type you can control the sidebar with the function I posted above. Your not messing with any templates are you?

    This wouldn’t have any effect on any post meta? And no the theme doesn’t add any extra database tables.


    Thanks for your patience, Ben, and sorry if I can’t explain the problem properly because of my poor English.

    I realized that the cpt shows the sidebar properly if it’s created as the cpt, but if I switch an existing regular post to cpt, the sidebar shown is empty (no widgets are shown). If I switch the theme, everything’s ok again.

    Thanks again.

    if I switch an existing regular post to cpt

    Help me understand what you are doing when you say this.

    Converting published posts to a diferent custom post type.

    Sorry, I was asking what method you are using. For example are you opening up a post copying the content then creating a new post that is a custom post type and pasting that content into the new custom post?

    Help me understand so I could potentially recreate.

    Also can you please confirm that in each of your sidebar widget areas you have content (appearance > widgets)

    Sorry, I misunderstood you 🙂

    If I create a new custom post from scratch, even if I do it by copying the title and content from a post (the cpt has no taxonomies) it shows the sidebar perfectly, but if I switch the post type from post to relatos (that’s the name of the cpt) the sidebar is empty. I’ve tried to do it with two different plugins (Post Type Switcher, one by one and in bulk mode, and Post Type Convertr) and going to the database and manually changing the value of post_type from “post” to “relatos”, and it always leads to the same: empty sidebar.

    All existing sidebars (my client created a custom one via the theme options) have content in. If you want I can give you access, since it’s a copy of the site in my staging server.

    Many thanks again.

    So your issue is mostly with your convertr? You can email me

    No, its not. As I said, with any other theme the sidebar works perfectly, is Virtue the only one with the issue.

    ok, I just did a bunch of testing. I created a post type, used the post-type-switcher and had no issue with the sidebar. I tried and tried to create one and I can’t. Are you sure you are not overriding templates?


    Completely sure. I have just done a pair of tests:

    * I created a new different cpt by using a code from generatewp, switched a post to cpt, and no sidebar

    * I made a clean install of WordPress in a local server (until now I’ve been using a VPS), with no plugins. I’ve installed a Genesis child theme and Virtue Premium, created a cpt and, again, switched a post to cpt. No issues with Twenty Sixteen or Genesis. No sidebar with Virtue Premium.


    I’m not sure I understand why you would use a Genesis child theme but that really shouldn’t matter.

    I’ve sent you my email address. I don’t know what else to say I can’t recreate your error but I’m certainly willing to help. If you want to send me your code and screen shots of your settings page or something else I would be happy to take a look.


    Solved at last!

    Finally Ben provided the solution, using this filter:

    add_filter('kadence_sidebar_id', 'custompost_sidebar_id');
    function custompost_sidebar_id($sidebar) {
      if(is_singular( 'custom-post-type' )) {
          $sidebar = 'sidebar-primary';
      return $sidebar;

    Many thanks Ben and Hannah for your valuable help!

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