0

I've added categories and tags to pages, but now I'm trying to add these to a page, but it doesn't show anything unless I add the category to a post...

Could someone take a look at what I'm doing wrong?

  // The Query
  query_posts( array ( 'category_name' => 'powershell-start', 'posts_per_page' => -1 ) );

  // The Loop
 while ( have_posts() ) : the_post(); ?>
    <li>
    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
  </li>

  <?php endwhile;

  // Reset Query
  wp_reset_query();

  ?>

EDIT: I'm sorry I notice im not clear. I'm trying to show a specific category on a page with the tilte and link to each page. But the above part only works when I add the category to a post instead of a page.

This is what I added to my functions.php:

/* add categories and tags to pages */
function add_taxonomies_to_pages() {
 register_taxonomy_for_object_type( 'post_tag', 'page' );
 register_taxonomy_for_object_type( 'category', 'page' );
 }
add_action( 'init', 'add_taxonomies_to_pages' );

1 Answer 1

-1

(I can't comment) How I get it you want to show all posts on specific category on page?

(Question1)

But how you add categories on pages? Using plugin or?

Solution that worked:

Link - He haven't put more hooks and filters to his query

3
  • nop, I added this: Commented Jul 28, 2017 at 14:31
  • /* add categories and tags to pages */ function add_taxonomies_to_pages() { register_taxonomy_for_object_type( 'post_tag', 'page' ); register_taxonomy_for_object_type( 'category', 'page' ); } add_action( 'init', 'add_taxonomies_to_pages' ); Commented Jul 28, 2017 at 14:31
  • Have you added pre_get_posts ? There is more info at spicemailer.com/wordpress/add-categories-tags-pages-wordpress
    – Wh0CaREs
    Commented Jul 28, 2017 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.