WordPress.org

Forums

[resolved] Multiple categories (2 posts)

  1. Alain Lankers
    Member
    Posted 3 years ago #

    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?

  2. Andrew
    Forum moderator
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.