• Resolved racesnearme

    (@racesnearme)


    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)
  • 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.

    Thread Starter racesnearme

    (@racesnearme)

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

    Thread Starter racesnearme

    (@racesnearme)

    thanks

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