• Resolved Laly York

    (@lalyry)


    Hello!
    At the link I shared, I’m still using the twenty twenty theme (with a child theme)

    What I need is to replicate what I did for paginated posts (see the link), with the twenty twenty two theme.
    Basically I split my posts in two, to show the footnotes on a next page; and I use the pagination to get “see footnotes” and “back to article” buttons instead of: “Pages: 1, 2”
    Of course, this is only meant for posts like this, split in two pages.

    Since the twentytwentytwo theme doesn’t allow to change the PHP file, I need to use the apply_filter() for wp_link_pages(), and I have no idea how to do that.

    So far, I managed to do the following with add_filter() instead:
    (in a child theme for twenty twenty two)

    add_filter( 'wp_link_pages_args', 'my_function');
    function my_function(){
      $args = array(
                                'before'      => '<div>',
                                'after'       => '</div>',
                                'link_before' => '<span class="page-number">',
                                'link_after'  => '</span>',
                                'next_or_number'    => 'next',
                                'separator'         => ' | ',
                                'nextpagelink'      => __( 'See the footnotes', '' ),
                                'previouspagelink'  => __( 'Back to article', '' ),
                                'echo'              => 1
    
      );
      return $args;
    }

    It works, but since I’m not using apply_filter() as I should, I see the pagination also above the page (on the upper left corner, inside the body)
    I guess it’s because I’m not using the hook I need to use and because I’m not defining the $output.

    I have no idea how to do it.

    Thank you so much in advanced!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • In your code, you just need to change 'echo' => 1 to 'echo' => 0

    I think that should fix the issue.

    Thread Starter Laly York

    (@lalyry)

    It did!
    Thank you so much!
    At least that is fixed

    Do you you know how to replicate this using apply_filter() and wp_link_pages()?

    You don’t need to use the wp_link_pages filter to change the links in the way that you want.

    The wp_link_pages_args filter in your code is all you should need to do.

    Thread Starter Laly York

    (@lalyry)

    ok, thank you for your time

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to use apply_filter to wp_link_pages in functions file’ is closed to new replies.