Forums

Issue with category name based post display (2 posts)

  1. ceejaybee
    Member
    Posted 1 year ago #

    I have a issue with my archive display..

    Issue details as follows;

    My query searches for the posts using the category name.

    If the category name comes as a single word such as "car" it returns the post list. However it fails for the category names such as "toyota cars"

    sample code would be;
    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. MichaelH
    Volunteer
    Posted 1 year ago #

    Try this instead:

    $cat_id = get_cat_ID('your category');
    $args=array(
      'cat' => $cat_id,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);

Topic Closed

This topic has been closed to new replies.

About this Topic