[resolved] Display Posts from one category only (4 posts)

  1. racesnearme
    Posted 2 years ago #

    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.

  2. WPShowCase
    Posted 2 years ago #

    Perhaps WordPress does this without you having to write any php.

    If you got to a url like example.com/category/arizona then you would see all the posts in the arizona category.

  3. racesnearme
    Posted 2 years ago #

    I figured it out. 'term'=> insert arizona, or california, etc here and it worked like a charm. Thanks for the response.

  4. racesnearme
    Posted 2 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic