Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • On second thought, here’s a better solution:

    function dr_previous_posts_link($label = '', $pre = '', $post = '') {
    	ob_start();
    	previous_posts_link($label);
    	$buffer = ob_get_contents();
    	ob_end_clean();
    	if(!empty($buffer)) echo $pre,$buffer,$post;
    }
    
    function dr_next_posts_link($label = '', $pre = '', $post = '') {
    	ob_start();
    	next_posts_link($label);
    	$buffer = ob_get_contents();
    	ob_end_clean();
    	if(!empty($buffer)) echo $pre,$buffer,$post;
    }

    Then call them like this:

    <?php dr_previous_posts_link('&laquo; <i>newer</i>', '<h4 class="posts_nav">', '</h4>'); ?>
    <?php dr_next_posts_link('<i>older</i> &raquo;', '<h4 class="posts_nav">', '</h4>'); ?>

    Here’s my solution. Pretty verbose, but I wanted to avoid the performance overhead of eval();*

    function dr_previous_posts_link() {
    	ob_start();
    	previous_posts_link('&laquo; <i>newer</i>');
    	$buffer = ob_get_contents();
    	ob_end_clean();
    	if(!empty($buffer)) echo "<h4 class=\"posts_nav\">$buffer</h4>";
    }
    
    function dr_next_posts_link() {
    	ob_start();
    	next_posts_link('&raquo; <i>older</i>');
    	$buffer = ob_get_contents();
    	ob_end_clean();
    	if(!empty($buffer)) echo "<h4 class=\"posts_nav\">$buffer</h4>";
    }

    *Using eval(); you could do something like this:

    function if_echo($code_string) {
    	ob_start();
    	eval($code_string);
    	$buffer = ob_get_contents();
    	ob_end_clean();
    	if(!empty($buffer)) echo $buffer;
    }

    With something like this in a template:

    <?php if_echo('next_posts_link()'); ?>

    <?php wp_list_bookmarks('title_li=&categorize=0'); ?>

Viewing 3 replies - 1 through 3 (of 3 total)