WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Multiple categories

[Resolved] Multiple categories

  • I have a front page with an overview of 2 categories, lets say fruits and vegetables:
    <?php query_posts(‘category_name=fruits,vegetables&showposts=4’); ?>

    When you ‘click read more’ you go to single.php. Part of the code there is:

    <?php while ( have_posts() ) : the_post(); ?>
    <?php
    // Get the ID of a given category
    $category_id = get_cat_ID( ‘Fruits’ );
    // Get the URL of this category
    $category_link = get_category_link( $category_id );
    ?>
    <!– Print a link to this category –>
    <p><a href="<?php echo esc_url( $category_link ); ?>" title="Go Back">« Go Back</a></p>

    I can only put 1 category in this line of code $category_id = get_cat_ID( ‘Fruits’ );

    Is it possible to have multiple categories? What I want is that when I click Go Back on fruits I will go back to an overview with only fruits; and when I click Go Back on vegetables I will go back to an overview with only vegetables?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Multiple categories’ is closed to new replies.
Skip to toolbar