wordpress怎么添加相关文章

puppy

<div> ??????????? ?<?php $backup = $post; $tags = wp_get_post_tags($post->ID); $tagIDs = array(); if ($tags) { echo ‘<h4>或许你会感兴趣的文章</h4>’; echo ‘<ul>’; $tagcount = count($tags); for ($i = 0; $i < $tagcount; $i++) { $tagIDs[$i] = $tags[$i]->term_id; } $args=array( ‘tag__in’ => $tagIDs, ‘post__not_in’ => array($post->ID), ‘showposts’=>8, // 显示相关日志篇数 ‘caller_get_posts’=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><span><?php the_time(__(‘Y-m-d’)) ?></span><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a></li> <?php endwhile; echo ‘</ul>’; } else { ?> <ul> <?php query_posts(array(‘orderby’ => ‘rand’, ‘showposts’ => 8)); //显示随机日志篇数 if (have_posts()) : while (have_posts()) : the_post();?> <li><span><?php the_time(__(‘Y-m-d’)) ?></span><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a></li> <?php endwhile;endif; ?> </ul> <?php } } $post = $backup; wp_reset_query(); ?>

wordpress怎么添加相关文章


< php
$backup = $post;
$tags = wp_get_post_tags($post->ID);
$tagIDs = array();
if ($tags) {
echo ‘

或许你会感兴趣的文章

’;
echo ‘
    ’;
    $tagcount = count($tags);
    for ($i = 0; $i < $tagcount; $i++) {
    $tagIDs[$i] = $tags[$i]->term_id;
    }
    $args=array(
    ‘tag__in’ => $tagIDs,
    ‘post__not_in’ => array($post->ID),
    ‘showposts’=>8, // 显示相关日志篇数
    ‘caller_get_posts’=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); >
  • < php the_time(__(‘Y-m-d’)) >” rel=”bookmark” title=”< php the_title(); >”>< php the_title(); >

  • < php endwhile;
    echo ‘
’;
} else { >

< php }
}
$post = $backup;
wp_reset_query();
>


相关推荐
  • 用WordPress打造项目管理系统
  • WordPress CMS主题:ReadersMag使用文档
  • 在WordPress第一篇文章里添加广告
  • 10款WordPress必装插件
  • WordPress视频主题VodPod使用教程
  • 系统推荐
  • WordPress 最新版本下载
  • Wordpress怎么给博客标题加上页码,减少标题重复
  • 教你如何修改wp自带的小工具
  • wordpress怎么给网站添加QQ漂浮客服代码
  • web环境下的各种wordpress伪静态规则

  • puppy

    官方运营-Sean丶♥

    5187 SEO文章

    评论