Title: WordPress Custom Query Variable + WP_Link_Pages
Last modified: March 4, 2018

---

# WordPress Custom Query Variable + WP_Link_Pages

 *  [gbrown442](https://wordpress.org/support/users/gbrown442/)
 * (@gbrown442)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/wordpress-custom-query-variable-wp_link_pages/)
 * 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](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/wordpress-custom-query-variable-wp_link_pages/#post-10037948)
 * 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.

## Tags

 * [wp_link_pages](https://wordpress.org/support/topic-tag/wp_link_pages/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/wordpress-custom-query-variable-wp_link_pages/#post-10037948)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
