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 $sibling->post_title;
        echo get_the_post_thumbnail($sibling->ID,'medium');
        //end of whatever you need to output//
    endforeach;
endif; //ends if( $parent ) //
?>      
4

1 回答 1

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 ) //
?>      

Α虽然这是一个简单的问题,只要稍加搜索,您就会自己找到答案

于 2013-11-13T00:19:06.120 回答