I'm trying to implement tags on my pages, so pages show up in the tag clouds I have printing in various places on the site.
The problem? If I tag a page, it doesn't show up in the list. Only posts do. I'm using the following in my functions.php to enable page tags:
// add tag support to pages
function tags_support_all() {
register_taxonomy_for_object_type('post_tag', 'page');
}
// ensure all tags are included in queries
function tags_support_query($wp_query) {
if ($wp_query->get('tag')) $wp_query->set('page_type', 'any');
}
// tag hooks
add_action('init', 'tags_support_all');
add_action('pre_get_posts', 'tags_support_query');
My tag.php page has the following:
<?php while (have_posts()) : the_post(); ?>
<h2 class="category-title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ? >" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" style="color:#000;"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php if ($wp_query->max_num_pages > 15) : ?>
<nav class="post-nav">
<ul class="pager">
<li class="previous"><?php next_posts_link(__('← Older posts', 'roots')); ?> </li>
<li class="next"><?php previous_posts_link(__('Newer posts →', 'roots')); ?> </li>
</ul>
functions.php
, should$wp_query->set('page_type', 'any')
be$wp_query->set('post_type', 'any')
instead?