plugins – Excluding specific post from custom next/previous theme function

Question

My Genesis child theme comes with its own plugin to customize the design. They recently added a Next/Prev post thumbnails bock at the bottom of the content area.

The only problem is that some of my posts have dynamic content that elongate the page and cause overlap issues, so I’d like to exclude those dynamic pages from using this function.

Within the themes plugin, they seem to use this to add it the backend setting and output:

add_action( 'after_setup_theme', __NAMESPACE__ . '\\set_modern_prev_next', 101 );
/**
 * Modern Prev + Next 
 */
function set_modern_prev_next() {
    if ( '1' === Settings::get( 'modern_prev_next' ) ) {
        remove_action( 'genesis_after_entry_content', 'genesis_prev_next_post_nav', 5 ); // for Foodie, Cook'd.
        add_action( 'genesis_after_entry_content', __NAMESPACE__ . '\\modern_prev_next', 5 );
    }
}
function modern_prev_next() {
    
    if ( ! is_singular( 'post' ) ) { return; }

I’ve been going through the WordPress documentation, and found the use of filters could solve this. I’ve added this snippet:

add_action('template_redirect', 'excl_modern_prev_next', 10 );
function excl_modern_prev_next() {
    if ( is_singular('11717') ) {
        remove_action( 'genesis_after_entry_content', 'modern_prev_next', 5 );
    }
}

But it doesn’t seem to work, I’m not sure if it’s the hook, priority or something else that I’m overlooking?

Thank you.

0
user224496 1 week 2022-07-29T18:05:37-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse