WordPress发布带有图像按钮的分页?

时间:2012-06-21 作者:ad2003

我正在尝试这样的后分页:

button left image | 1 2 3 4 5 |button right image

但我不能让它工作。我尝试过:

<?php wp_link_pages(\'before=<p>&after=</p>&next_or_number=number&pagelink= %\'); ?>

但是如何将图像作为按钮添加到左侧和右侧?thx!公元

2 个回复
最合适的回答,由SO网友:ad2003 整理而成

是的,现在可以了!谢谢

我用这个密码[\'next_or_number\'] == \'next_and_number\') 因此,我可以将其与数字、箭头或图形混合使用:

// Custom Next/Previous Page
add_filter(\'wp_link_pages_args\', \'wp_link_pages_args_prevnext_add\');
/**
 * Add prev and next links to a numbered link list
 */
function wp_link_pages_args_prevnext_add($args)
{
    global $page, $numpages, $more, $pagenow;

    if (!$args[\'next_or_number\'] == \'next_and_number\') 
        return $args; # exit early

    $args[\'next_or_number\'] = \'number\'; # keep numbering for the main part
    if (!$more)
        return $args; # exit early

    if($page-1) # there is a previous page
        $args[\'before\'] .= _wp_link_page($page-1)
            . $args[\'link_before\']. $args[\'previouspagelink\'] . $args[\'link_after\'] . \'</a>\'
        ;

    if ($page<$numpages) # there is a next page
        $args[\'after\'] = _wp_link_page($page+1)
            . $args[\'link_before\'] . $args[\'nextpagelink\'] . $args[\'link_after\'] . \'</a>\'
            . $args[\'after\']
        ;

    return $args;
}
要获取分页导航:

<?php
wp_link_pages(array(
        \'before\' => \'<div class="pagenav">\' . __(\'\'),
       \'after\' => \'</div>\', 
        \'next_or_number\' => \'next_and_number\', # activate parameter overloading
        \'nextpagelink\' => __(\'<img src="\'.get_bloginfo(\'template_url\').\'/images/nxt_btn.png" />\'),
        \'previouspagelink\' => __(\'<img src="\'.get_bloginfo(\'template_url\').\'/images/prv_btn.png" />\'),
    \'pagelink\' => \'%\',
    \'echo\' => 1 )
);
?>
谢谢大家!

公元

SO网友:Grávuj Miklós Henrich

关于wp\\u link\\u页面功能,您可以在WordPress Codex中阅读http://codex.wordpress.org/Function_Reference/wp_link_pages.

给你:

wp_link_pages(
    array(
        \'before\' => \'<div class="pagenav">\',
        \'after\' => \'</div>\', 
        \'next_or_number\' => \'next\', 
        \'nextpagelink\' => __(\'<img src="IMAGE SRC HERE" />\'), 
        \'previouspagelink\' => __(\'<img src="IMAGE SRC HERE" />\')
    )
);
祝你好运!:)

结束

相关推荐

Delete Child Posts

当父帖子被删除时,我正在尝试删除所有子帖子。父帖子删除得很好,但子帖子没有正确删除。以下是我现在掌握的代码:$args = array( \'post_parent\' => $parentid, \'post_type\' => \'custom-type\' ); $posts = get_posts( $args ); if ($posts) {