0

I have next and prev with a gallery and the select is not ok and I have no idea how to change. I want to make the select by two category not by a status (publish)

function in_conference_prev_next_posts() {
    $cmsmasters_post_type = get_post_type();

    $published_posts = wp_count_posts($cmsmasters_post_type)->publish;


    if ($published_posts > 1) {
        echo '<aside class="post_nav">';

        previous_post_link('<span class="cmsmasters_prev_post">%link<span class="cmsmasters_prev_arrow"><span></span></span><span class="sub">previous</span></span>');

        next_post_link('<span class="cmsmasters_next_post">%link<span class="cmsmasters_next_arrow"><span></span></span><span class="sub">next</span></span>');

        echo '</aside>';
    }
}
0

See: https://codex.wordpress.org/Function_Reference/previous_post_link

I'm a little confused by what you are asking but I'm assuming you are after the next/prev links to go to the next or previous post in the same category? In which case, you need to define the third argument in 'previous_post_link' & 'next_post_link' as 'true'.

Note that those two functions must be used inside "the loop" to work.

  • Now the request is working for all the cateogries..but I want to make for just two category not for all – Youpirse1978 Oct 11 '16 at 15:14
  • Then you'll need to exclude using the fourth parameter. – Steve North Oct 11 '16 at 15:17
  • But I want two exactly category from all..how can I do this? on my code – Youpirse1978 Oct 11 '16 at 15:34
  • You could query the posts based on the two categories and it would get the next/prev items from those two categories using: 'category' => array(1,2) With get_posts(); – Steve North Oct 11 '16 at 15:59
  • Can you help me..Not working for me..I don't know how to implement in my code – Youpirse1978 Oct 11 '16 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.