• Thanks for any help in advance!

    I am using a custom Query in WordPress. Everything related to the Query is working. The issue I’m having is depending on wether the Query is empty or not, I’m trying to display wp_link_pages.

    The issue I’ve ran into is when the Query is empty I want it to exclude ‘wp_link_pages’. It does this but then doesn’t show the rest of the content.

    Are there any ways to get the rest of the content?

    Code below is working, I’m just unable to see the full article.

    Thanks

    $custom_var = get_query_var( 'custom_var' );
    
    if(empty($custom_var)) {
    
    wp_link_pages(
         array(
          'next_or_number' => 'next', 
          'before' => '<div id="link-pages">', 
          'after' => '</div>', 
          'link_before' => '',
          'link_after' => '',
          'previouspagelink' => '<div class="before-prev"></div>', 
          'nextpagelink' => '<div class="before-next">NEXT ></div>'
         )
        );
    }
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    When you break up a post into its own pages, the subsequent sections still have to be requested individually, whether there are links leading there or not. To get around this, you need to subvert the entire post pagination process.

    There is a filter that allows us to manage the pages that are divided up in a post called “content_pagination”. Hook this filter and if the query var value exists, implode the passed page element array back into one block of content.

    By doing this, the post is no longer multipage and wp_link_pages() will not display anything even without your conditional. If there are multipage posts that must still be multipage even without the query var being set, you need to somehow distinguish between those and the situation you are addressing, as the filter is applied to all multipage post content.

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress Custom Query Variable + WP_Link_Pages’ is closed to new replies.