如何修改代码将页面列表转换为可点击的链接?

时间:2013-11-12 23:59:53

标签: wordpress list linked-list

我有以下代码在侧边栏中显示兄弟页面及其缩略图。我如何修改它以使标题包含超链接?

<?php global $post; //not neccessary if used in the loop
$parent = $post->post_parent; 
if( $parent ) :
    $siblings = get_pages( 'child_of=' . $parent . '&parent=' . $parent . '&exclude=' 
. $post->ID);
    if( $siblings ) foreach( $siblings as $sibling ) :
        //start of whatever you need to output//
        echo $sibling->post_title;
        echo get_the_post_thumbnail($sibling->ID,'medium');
        //end of whatever you need to output//
    endforeach;
endif; //ends if( $parent ) //
?>      

1 个答案:

答案 0 :(得分:0)

<?php global $post; //not neccessary if used in the loop
$parent = $post->post_parent; 
if( $parent ) :
    $siblings = get_pages( 'child_of=' . $parent . '&parent=' . $parent . '&exclude=' 
. $post->ID);
    if( $siblings ) foreach( $siblings as $sibling ) :
        //start of whatever you need to output//
        echo '<a href="'. get_page_link( $sibling ->ID ) . '">' . $sibling->post_title. '</a>';
        echo get_the_post_thumbnail($sibling->ID,'medium');
        //end of whatever you need to output//
    endforeach;
endif; //ends if( $parent ) //
?>      

虽然这是一个简单的问题,但通过一点点搜索,你会自己找到答案