admin管理员组

文章数量:1278983

I have a post type called families where I add personal information of each family, inside the data there is an option called status.

*IMPORTANT: The fields are created with ACF CUSTOM FIELDS

These families are shown on one page each. For example

What I need is to exclude the families that do not have the status Retained, and that are not shown or linked in the next and back buttons.

in my code I have functions get_next_post_link() and get_previous_post_link()

<?php
$older_link = get_next_post_link( '%link', '<i class="far fa-angle-right"></i>' );
$newer_link = get_previous_post_link( '%link', '<i class="far fa-angle-left"></i>' );
$previous = '<span class="meta-nav">Previous Post</span>';
$next = '<span class="meta-nav">Next Post</span>';
?>
<nav class="d-flex align-items-center navigation navigation-single">
    <div class="arrows">
        <?php echo $newer_link; ?>
        <?php echo $older_link; ?>
    </div>
</nav>

Thank you very much for your help

I have a post type called families where I add personal information of each family, inside the data there is an option called status.

*IMPORTANT: The fields are created with ACF CUSTOM FIELDS

These families are shown on one page each. For example

What I need is to exclude the families that do not have the status Retained, and that are not shown or linked in the next and back buttons.

in my code I have functions get_next_post_link() and get_previous_post_link()

<?php
$older_link = get_next_post_link( '%link', '<i class="far fa-angle-right"></i>' );
$newer_link = get_previous_post_link( '%link', '<i class="far fa-angle-left"></i>' );
$previous = '<span class="meta-nav">Previous Post</span>';
$next = '<span class="meta-nav">Next Post</span>';
?>
<nav class="d-flex align-items-center navigation navigation-single">
    <div class="arrows">
        <?php echo $newer_link; ?>
        <?php echo $older_link; ?>
    </div>
</nav>

Thank you very much for your help

Share Improve this question edited Oct 14, 2021 at 19:41 dexter asked Oct 14, 2021 at 16:40 dexterdexter 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

What is Status? If it's a taxonomy - and, by the look of it, it should be - you can exclude any given term in get_previous_post_link using the $excluded_terms parameter.

If status is not a taxonomy already, you might want to rethink that for performance reasons.

本文标签: phpHow exclude or skip post type with getnextpostlink