0

I've bought a wordpress theme. I want to ignore all wp_link_pages functions from theme files. I will write my custom codes.

Is there any way to do it with functions.php

1 Answer 1

2

wp_link_pages has two filters you can use:

  • The wp_link_pages_args filter is passed the $args for wp_link_pages so you could set echo to false.

  • The wp_link_pages filter is passed the output so you could set the output to nil. Something like this should work:

/**
 * Filter the HTML output of page links for paginated posts.
 *
 * @param  string $output HTML output of paginated posts' page links.
 * @param  array  $args   An array of arguments.
 * @return string $output HTML output of paginated posts' page links.
 **/
add_filter('wp_link_pages', 'wpse_218590_hide_wp_link_pages', 10, 2);
function wpse_218590_hide_wp_link_pages( $output, $args )
{
    return '';
}

This isn't tested and I only had a quick look at the filters so it may not be 100% correct but it should give you an idea of what to do

4
  • Thanks CAI. It removed all wp_link_pages. But how can I write my custom wp_link_pages code?
    – sakarya
    Feb 23, 2016 at 14:50
  • Thats doable.. but you should probably ask a new question for that as it's way out of the scope of this question.
    – Cai
    Feb 23, 2016 at 14:54
  • added wp_link_pages() function to custom_wp_link_pages() now, it works..
    – sakarya
    Feb 23, 2016 at 15:03
  • Glad you got it working :)
    – Cai
    Feb 23, 2016 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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