Get post by category_name
-
This is probably simple for advanced users, but I am a bit stuck. I am using the default example that the plugin author provides in Contact Form 7:
Categories (required) <br/> [checkbox* post_category_name "Uncategorized" "Cat1" "Cat2" "Cat3"] <br/>
I am able to get this working with posts showing up on the blog page. What I would like to do is configure the site so that posts show on different pages based on what category the poster checks off in the checklist. I am using this code straight from the WordPress codex:
<?php
$args = array( 'category_name' => 'Cat1' ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php endforeach; wp_reset_postdata();?>
But I am not getting the post to show up on the relevant page. It’s still just showing up on the general blog page. Any help?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get post by category_name’ is closed to new replies.