Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

navyspitfire on "Target only pages in the same category"

$
0
0

I've been scrapping together pieces of code, but with this code I am trying to have it so it only targets pages in the same category. Ideas?

<div class="port-nav left">
        <?php
            /**
             *  Infinite next and previous post looping in WordPress
             */
            if( get_adjacent_post(false, '', true) ) {
        ?>
                <p class="prev"><?php previous_post_link('%link'); ?></p>
        <?php
            } else {
                $first = new WP_Query('posts_per_page=1&order=DESC'); $first->the_post();
                    echo '<a href="' . get_permalink() . '">&larr; Previous Post</a>';
                wp_reset_query();
            };
        ?>
        <?php
            if( get_adjacent_post(false, '', false) ) {
        ?>
                <p class="next"><?php next_post_link('%link'); ?>
        <?php
            } else {
                $last = new WP_Query('posts_per_page=1&order=ASC'); $last->the_post();
                    echo '<a href="' . get_permalink() . '">Next Post &rarr;</a>';
                wp_reset_query();
            };
        ?>
    </div>

Viewing all articles
Browse latest Browse all 8245

Trending Articles