WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
[resolved] Returning a string, not printing it directly (2 posts)

  1. eqhes
    Member
    Posted 3 years ago #

    WP-PageNavi version: 2.73

    If you need that wp_pagenavi returns a string and not directly prints its result, you can do this:

    On wp-pagenavi.php add ['return_string' => 0,] after line 51. You now will see something like this:

    [...]
    'use_pagenavi_css' => true,
    'style' => 1,
    'return_string' => 0,
    [...]

    Now, on core.php replace [echo apply_filters( 'wp_pagenavi', $out );] on line 144 by this:

    $out = apply_filters( 'wp_pagenavi', $out ); //edit: añadido todo el final de la función; orig : echo apply_filters( 'wp_pagenavi', $out );
    if( ! $options['return_string'] ){
    	echo $out;
    }else{
    	return $out;
    }

    Finally, you can call the function like this:
    if(function_exists('wp_pagenavi')) { $custom_variable = wp_pagenavi( '', '', array('return_string' => TRUE) ); }

    And print $custom_variable where you like it ;).

    It would be great to see this option enabled by default on WP-PageNavi (on version: 2.74 maybe? :D).

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Or, you could just do this:

    ob_start();
    wp_pagenavi();
    $output = ob_get_clean();

    $output will contain the entire string generated by WP Pagenavi.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic