• Hello, in this version of wordpress when i use “category_name => slug” wp_query show all posts, not only the posts in category associated.
    otherwise if i use “cat => ID” it works fine
    anyone have the same issue?
    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • category_name accepts category slug, make sure you are naming your slug correctly.

    Thread Starter drago.uix

    (@dragouix)

    yes i’ve check the slug also in the database and i’ve also create a new custom theme whit only this in function file:
    <?
    $speciali = new WP_Query( array(‘category_name’ => ‘speciali’, ‘posts_per_page’ => 4));
    ?>
    otherwise:
    <?
    $speciali = new WP_Query( array(‘cat’ => ’14’, ‘posts_per_page’ => 4));
    ?>
    works fine :/

    I’m not sure why this is happening though, I don’t have a complete view how you are doing it. But may I know why you are still want to use slug if ID is working for you?

    Thread Starter drago.uix

    (@dragouix)

    I’m using id in fact, however, but i wanted to know if someone had the same problem for information purposes.
    You have tried to handle this?
    (the same theme in wordrpress 4.3 works fine)

    I tested on WordPress 4.4 and its working fine there.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_query -> category_name’ is closed to new replies.