WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Display Posts from one category only

[Resolved] Display Posts from one category only

  • I’ve been through all the different walk thrus on here. None seem to match up to my code. Or I’m just scared of PHP
    I have a custom post type named ‘events’ and I have categories of all 50 states. I only want to display events of the same state on each page. I have the page setup. I can create 50 different pages. But I cant figure out how to only show certain states. Now I have setup categories. I can’t tell their #’s (maybe someone can show me how) but they are named Arizona, California, etc…same with the slugs. Here is the code of my ‘upcoming events’ page that I am using.

    <div class=”ev2page clearfix”>
    <div class=”title-head”><h1>Upcoming Events</h1></div>’;
    $term = get_queried_object()->slug;
    $query = array(
    ‘post_type’ => ‘event’,

    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘asc’,
    ‘posts_per_page’ => 10,
    ‘meta_value’ => strftime(“%Y/%m/%d”, time()- (60 * 60 * 24) ),
    ‘meta_key’ => ‘event_date_interval’,
    ‘meta_compare’ => ‘>’,
    ‘taxonomy’ => ‘events’,
    ‘term’ => $term

    Thank you for looking at this for me.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Display Posts from one category only’ is closed to new replies.
Skip to toolbar