Support » Plugin: WP-PageNavi » [Plugin: WP-PageNavi] Returning a string, not printing it directly

  • Resolved eqhes


    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;
    	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).

Viewing 1 replies (of 1 total)
  • Plugin Author scribu


    Or, you could just do this:

    $output = ob_get_clean();

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

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WP-PageNavi] Returning a string, not printing it directly’ is closed to new replies.