Title: display_ca_sidebar ?
Last modified: August 22, 2016

---

# display_ca_sidebar ?

 *  Resolved [thisismyalias](https://wordpress.org/support/users/thisismyalias/)
 * (@thisismyalias)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/)
 * You have built a great plugin here. It’s logic, for me, is better than the biggest
   custom sidebar plugin.
 * It works perfectly with my theme; however, it doesn’t work with the custom page
   templates I made. I’m not sure what I’m missing to cause this.
 * I understand that this question may be outside of the scope of support you’re
   willing to offer, but I have to try asking. I’m not sure if “display_ca_sidebar”
   is something I am supposed to use to get the sidebars to appear on my custom 
   templates (like the sidebars do on all of the theme’s other posts/pages).
 * Thank you.
 * [https://wordpress.org/plugins/content-aware-sidebars/](https://wordpress.org/plugins/content-aware-sidebars/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [thisismyalias](https://wordpress.org/support/users/thisismyalias/)
 * (@thisismyalias)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538809)
 * Well, to follow up in case you read this, I see now that display_ca_siebar isn’t
   a solution to my problem.
 * I have a custom template, which does display the Pages sidebar, just like other
   origional theme pages. However, the sidebars created with this plugin will not
   display on this custom template. It’s odd that sidebars work on the custom template,
   but not sidebars created with this plugin.
 * I also discovered that the plugin does work with other custom pages – I took 
   an origional theme page template (template-faq.php) and renamed it to create 
   a custom page template. The plugin works on this custom template. This tells 
   me that somehow the custom template that isn’t working has something in it that
   is messing things up.
 *  Plugin Author [Joachim Jensen](https://wordpress.org/support/users/intoxstudio/)
 * (@intoxstudio)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538811)
 * Thanks for your feedback.
 * When you are referring to Page Templates, do you then mean the templates you 
   can select in the page editor? Or is it templates that are automatically loaded
   by your theme?
 * Also, did you check that you selected the right Host Sidebar when creating a 
   new sidebar, e.g. _Replace: Pages sidebar_?
 * `display_ca_sidebar()` is a function you can use if your theme does not have 
   any “original” sidebars, or if you want the content aware sidebars to be displayed
   in a specific spot in your theme. It will display sidebars with the _Manual _handle.
 *  Thread Starter [thisismyalias](https://wordpress.org/support/users/thisismyalias/)
 * (@thisismyalias)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538813)
 * Hi. Thanks for the response. I have made sure I’m selecting the right Host Sidebar
   in Replace: Pages.
 * The page templates I’m referring to are the ones that can be selected in the 
   page editor. For example, I add a new page and select the custom page template(
   custom = I made it…my theme comes with templates that are not found in the core
   of WordPress though). The custom template is called “Departments”. The default
   sidebar for pages do appear on pages made with this template, but sidebars made
   with your plugin do not. The exact same sidebars work with every other template
   page aside from my custom ones.
 * I’m not sure what you mean by “templates that are automatically loaded by your
   theme.”
 *  Plugin Author [Joachim Jensen](https://wordpress.org/support/users/intoxstudio/)
 * (@intoxstudio)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538815)
 * Do you have any custom database queries in your custom templates? If yes, you
   should remember to use `wp_reset_postdata()`. Read more here: [http://codex.wordpress.org/Class_Reference/WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query)
 * What I mean about templates being automatically loaded by your theme, is that
   some themes/theme frameworks have different ways to load custom templates based
   on different parameters.
 *  Thread Starter [thisismyalias](https://wordpress.org/support/users/thisismyalias/)
 * (@thisismyalias)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538818)
 * The custom template must be using custom database queries. I read the article
   on wp_reset_postdata() but I didn’t learn yet where it goes.
 * That article made me think of trying something. I deleted out the part of the
   custom template with the new code (that I didn’t write) and the plugin worked
   as expected. So it does have something to do with the queries.
 * The section is:
 *     ```
       <section class="span4 articles-list" style="margin-left:0;">
       <!-- Best Practices  ID = 20-->
           <?php query_posts( array( 'category__and' => array($dept_id,20),
           'posts_per_page' => 5,
           'show_count' => 1 ) );
           $total_posts =$wp_query->found_posts;
           $myposts = $wp_query->post_count; 
   
           if ($myposts > 0) { ?>
               <h3><a href="/portal/?page_id=31?department_id=<?php echo $dept_id; ?>&department_name=<?php echo $deptname; ?>">Best Practices (<?php echo $total_posts; ?>)</a></h3>
               <?php while (have_posts()) : the_post(); ?>
               <ul class="articles">
          	        <li class="article-entry standard"><h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h4>
                   <span class="article-meta"><?php the_modified_date('F j, Y'); ?> in  <?php the_category(', ') ?> </span>
                   <span class="like-count"><?php echo get_total_likes($post->ID); ?></span>
                   </li>
               </ul>
       	<?php endwhile;
       	} ?>
       </section>
       ```
   
 * Thank you for the direction, I’m a little closer now.
 *  Plugin Author [Joachim Jensen](https://wordpress.org/support/users/intoxstudio/)
 * (@intoxstudio)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538819)
 * Yes, that query is altering the global post data. Furthermore, because it uses`
   query_posts()`, it also alters the global main query. You can read more about
   that here: [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
 * If you do not want your WordPress installation to think that the page is in fact
   a list of posts (this is what the query does), insert `wp_reset_query();` between
   the last `}` and `?>`
 *  Thread Starter [thisismyalias](https://wordpress.org/support/users/thisismyalias/)
 * (@thisismyalias)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538829)
 * Perfect! Thank you very much!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘display_ca_sidebar ?’ is closed to new replies.

 * ![](https://ps.w.org/content-aware-sidebars/assets/icon-256x256.png?rev=1815877)
 * [Content Aware Sidebars - Fastest Widget Area Plugin](https://wordpress.org/plugins/content-aware-sidebars/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/content-aware-sidebars/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/content-aware-sidebars/)
 * [Active Topics](https://wordpress.org/support/plugin/content-aware-sidebars/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/content-aware-sidebars/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/content-aware-sidebars/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [thisismyalias](https://wordpress.org/support/users/thisismyalias/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/display_ca_sidebar/#post-5538829)
 * Status: resolved