博客

  • 按分类调用标签 调用指定分类下的TAG

    <?php
    query_posts('category_name=news');
    if (have_posts()) : while (have_posts()) : the_post();
    if( get_the_tag_list() ){
    echo $posttags = get_the_tag_list('<li class="jquery">','</li><li>','</li>');
    }
    endwhile; endif;
    wp_reset_query();
    ?>

    在制作wordpress主题时,有时候会用到按分类调用标签的时候,用上面的这一段代码就可以解决。

  • WordPress子页面page调用父页面标题

    在需要调用的页面,添加以下代码就可以现实子页面调用父页面的标题。
    <?php
    if($post->post_parent) {
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    } else {
    wp_title('');
    }
    ?>