wordpress调用目录页

调用目录页:

<ul class="mproductpic">
	<?php if ($posts_perpage) { ?>
	<?php $postsperpage = $posts_perpage; ?>
	<?php } else { ?>
    <?php $postsperpage =6; ?>
    <?php } ?>
    <?php
						$categoryID=$cat;
						
						$wp_query = new WP_Query('cat=' . $categoryID. 'orderby=date&order=desc&posts_per_page='.$postsperpage.'&paged='.$paged); ?>
    <?php while (have_posts()) : the_post(); ?>
		
			
			<li>
				<a href=<?php the_permalink() ?> title="<?php the_title(); ?>"><?php if(function_exists('wp_thumbnails_for_homepage')) { wp_thumbnails_for_homepage(); } ?></a>

				<h2 class="mproductpicbt">
					<?php the_title(); ?>
				</h2>
			</li>
	    <?php endwhile; ?>
			<div class="clearfix"></div>
		</ul>

 

wordpress 获取相关文章两种方法 标签tag 和 目录category

1.使用当前文章tag获取:

<ul class="aboutCon">
<?php
global $post;
$post_tags = wp_get_post_tags($post->ID);
if ($post_tags) {
  foreach ($post_tags as $tag) {
    // 获取标签列表
    $tag_list[] .= $tag->term_id;
  }
 
  // 随机获取标签列表中的一个标签
  $post_tag = $tag_list[ mt_rand(0, count($tag_list) - 1) ];
 
  // 该方法使用 query_posts() 函数来调用相关文章,以下是参数列表
  $args = array(
        'tag__in' => array($post_tag),
        'category__not_in' => array(NULL),  // 不包括的分类ID
        'post__not_in' => array($post->ID),
        'showposts' => 6,                           // 显示相关文章数量
        'caller_get_posts' => 1
    );
  query_posts($args);
 $i=1;
  if (have_posts()) {
    while (have_posts()) {
      the_post(); update_post_caches($posts); ?>
    <li><br /><?php echo $i+".";?><?php the_title(); ?>
				<br /><?php the_excerpt(); ?>
				</li>
<?php
    }
  }
  else {
    echo '<li>* 暂无相关文章</li>';
  }
  wp_reset_query(); 
}
else {
  echo '<li>* 暂无相关文章</li>';
}
?>
				
			</ul>

2.使用目录category获取

<?php
			global $post;
			$cats = wp_get_post_categories( $post->ID );
			if ( $cats ) {
				$args = array(
					'category__in' => array( $cats[ 0 ] ),
					'post__not_in' => array( $post->ID ),
					'showposts' => 6,
					'caller_get_posts' => 1
				);
				query_posts( $args );

				if ( have_posts() ) {
					while ( have_posts() ) {
						the_post();
						update_post_caches( $posts );
						?>

			<li class="tuiJianCon last ">

				<ul class="tuiJianNews">

					<li class="font-24" id="shij">
						<?php the_time('d');?><br/>
						<span>
							<?php the_time('Y-m');?>
						</span>
					</li>
					<li class="newsBt"><a href=<?php the_permalink(); ?> title="<?php the_title(); ?>"><?php the_title(); ?></a>
					</li>
					<li class="newsCon"><a href=<?php the_permalink(); ?> title="">  
	<?php the_excerpt(); ?></a>
					</li>
					<div class="clearfix"></div>
				</ul>
			</li>


			<?php
			}
			} else {
				echo '<li>* 暂无相关文章</li>';
			}
			wp_reset_query();
			}
			else {
				echo '<li>* 暂无相关文章</li>';
			}
			?>

 

wordpress 代码实现分页

分页符调用:

<?php echo paginate_links(array(
    'prev_next'          => 0,
    'before_page_number' => '',
    'mid_size'           => 2,
));?>

分页CSS:

/*分页样式*/
.posts-nav {
	font-size: 14px;
	color:#000000;
	padding: 10px 0;
	margin: 0 auto;
	line-height:23px;text-align:center;
}
.posts-nav .page-numbers {
	border-radius: 3px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	display: inline-block;
	text-align: center;
	width: 30px;
	line-height: 30px;
	margin: 0 5px;
}
.posts-nav .page-numbers.current, .posts-nav .page-numbers:not(.dots):hover {
	background: #1F7508;
	border-color: #1F7508;
	color: #fff;
}
.posts-nav .page-numbers.dots {
	border-color: rgba(0,0,0,0)
}

 

 

CSS设置最大行高和最大宽度超出自动隐藏

CSS代码:

width: 255px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height:23px;
max-height: 46px;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;

将行高和最大行高设置为一样的值,-webkit-line-clamp: 1,限制行数,这样就可以定义超过一行自动隐藏的效果了;设置超过两行自动隐藏是效果,line-height和max-heinght成比例,-webkit-line-clamp设为2,

wordpress 免插件显示浏览量

在functions.php中放入以下代码:

/*显示文章浏览次数*/
function getPostViews($postID){
$count = get_post_meta($postID,'views', true);
if($count==''){
delete_post_meta($postID,'views');
add_post_meta($postID,'views', '0');
return "0";
}
return $count.'';
}
function setPostViews($postID) {
$count = get_post_meta($postID,'views', true);
if($count==''){
$count = 0;
delete_post_meta($postID,'views');
add_post_meta($postID,'views', '0');
}else{
$count++;
update_post_meta($postID,'views', $count);
}
}

调用代码:

<?php setPostViews(get_the_ID()); echo number_format(getPostViews(get_the_ID())); ?>

 

wordpress 调用指定分类文章不影响后面的the_post

调用代码:

<?php query_posts('cat=3&posts_per_page=4'); while(have_posts()): the_post(); ?>   
  <li>
				<a href=<?php the_permalink() ?> title="<?php the_title(); ?>">
					<?php if(function_exists('wp_thumbnails_for_homepage')) { wp_thumbnails_for_homepage(); } ?>
				</a>
				<h4><?php the_title(); ?></h4>
			</li>
<?php endwhile; wp_reset_query(); ?>

 

win10 10586升级14393步骤

1.下载win10 14393安装包

①win10 1607 32位,复制地址打开迅雷下载:
ed2k://|file|cn_windows_10_multiple_editions_version_1607_updated_jan_2017_x86_dvd_9714392.iso|3621646336|99C607CB5DEA2B245D131F03E5F6522F|/
②win10 1607 64位,复制地址打开迅雷下载:
ed2k://|file|cn_windows_10_multiple_editions_version_1607_updated_jan_2017_x64_dvd_9714394.iso|4747692032|27841B07666580185078EE62915191A1|/

2.右键管理员打开安装包

3.选择不是现在

4.选择接受

5.选择要保留的内容

6.接着重启进入这个界面,执行更新过程,该过程需多次重启