WordPress.org

Ready to get started?Download WordPress

Forums

Categories with Spaces (3 posts)

  1. vamped
    Member
    Posted 7 years ago #

    Hey guys,

    I'm using the following code in my Loop:

    <?php $my_query = new WP_Query('category_name=Fantasy/Science Fiction&showposts=5');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>

  2. " rel="bookmark" title="Read <?php the_title(); ?>'s Review!"><?php the_title(); ?>
  3. <?php endwhile; ?>

    The problem is that the categeory has a space in it, and the loop won't display it correctly.

    Anyone have a solution to this? It's very much appreciated.

    Thanks,

    James

  • Doodlebee
    Member
    Posted 7 years ago #

    Why don't you change it form "category name" to number?

    For example:

    WP_Query('category_ID=5&showposts=5');

    "5" being the ID number given to that category (It may be something else in your blog)

  • vamped
    Member
    Posted 7 years ago #

    Thanks ;D

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags