WordPress.org

Forums

[resolved] Category Name causing problems (3 posts)

  1. anatman
    Member
    Posted 4 years ago #

    Hi,

    I have just faced a problem where i wouldn't be able to list the posts in a category. All other categories would behave normally, except this one.
    First i found out that changing the name and slug of the category would make the problem go away and come back. Oddly enough, i narrowed the problem to the category name, or so it seems.

    Using a name like "Distraí-me", with the accented "i", caused the problem, but changing the name to "Distrai-me" ceases the problem. The code i am using to display the category posts is:
    <?php query_posts(array('category_name' => single_cat_title('', FALSE), 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => '-1')); ?>

    Please note that i am reffering to categry name, not slug. I suspect there is a problem with sanitizing the accented characters in category names (i had a similar problem before with the word "Vídeos", which i solved by accident).

    Can anyone help me with this, or help me to open an entry in the trac? (i can't really tell if this has already been reported).

    Thank you,
    Edaurdo

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    your code is simply ignoring the documentation:

    Please note that i am reffering to categry name, not slug.

    the codex states clearly that you need to use the slug:

    category_name (string) - use category slug (NOT name).

    http://codex.wordpress.org/Function_Reference/WP_Query#Category_Parameters

    you could try and work with the category id:

    <?php query_posts(array('cat' => get_query_var('cat'), 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => '-1')); ?>
  3. anatman
    Member
    Posted 4 years ago #

    Hi alchymyth,

    Now i understand what is going on! The code generating my page is from a premium theme, i just assumed it was right - sorry for the bug thing. If a moderator would correct this thread's title and remove the word bug, i'll be gratefull.

    Thanks a lot fro your help and for the code sugestion, i will try it now.

    best,
    Eduardo

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags