<?php get_header(); ?> 头部调用
<?php get_footer(); ?> 底部调用
<?php get_footer(); ?> 侧边栏调用
<link href="<?php bloginfo('template_url'); ?>/sy/css.css" type="text/css"> css路径,图片路径和js路径通用
<a href="<?php the_permalink(); ?>"> 文章详情跳转
<img src="<?php echo catch_that_image() ?>" alt="<?php the_title(); ?>"> 调用图片标签
<?php the_title(); ?> 文章标题
8.<?php the_tags(‘’); ? 标签调用
9.<?php echo mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 60, ‘……’); ?> 文章内容调用并限制字符
10.<?php echo date(“Y-m-d”);?> <?php echo date(“Y-m-d H-i”);?> 时间标签
11.<?php if (have_posts()):while(have_posts()) :the_post(); ?><?php the_content(); ?><?php endwhile; ?><?php endif; ?>文章内容
12.<?php bloginfo(‘name’); ?> 网站域名
13.<?php single_tag_title(); ?> tag标题
14.<?php single_cat_title(); ?> 分类页标题
调用id为1的文章 开始 <?php $the_query = new Wp_Query(array( ‘cat’ => 1, ‘orderby’ => ‘id’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 4, ‘paged’ => get_query_var(‘paged’, 1) )); ?> <?php if ($the_query->have_posts()) : ?> <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
主体内容
<?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?>调用id为1的文章 结束
<?php $terms = get_terms(‘category’, ‘orderby=name&hide_empty=0’); $count = count($terms); if ($count > 0) { foreach ($terms as $key => $term) { if ($key <= 4) { echo ‘<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-84"><a class="elementor-item" href="' . get_term_link($term, $term->slug) . '" >‘ . $term->name . ‘</a></li>‘; } } } ?>
(1)循环查询规则
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>开始
//循环主体
<?php endwhile; ?><?php endif; ?>结束
搜索框:
<form id="search_form" method="get" target="_search" action="<?php bloginfo('url'); ?>/" accept-charset="utf-8"> <input type="hidden" name="type" value="blog"> <input id="keyword" type="text" name="s" class="logoRDownC_input" value="<?php the_search_query(); ?>" placeholder="请输入搜索关键词"> <input type="submit" class="logoRDownC_input2" value="搜索"> </form>
<?phpfunction excerpttitle($max_length) { $title_str = get_the_title(); if(mb_strlen($title_str,’utf-8’) > $max_length) { $title_str = mb_substr($title_str,0,$max_length,’utf-8’).’…’; } return $title_str;}?>
调用方法:<a href="<?php the_permalink(); ?>"><?php echo excerpttitle(8); ?> </a>
<?php
if (isset($_GET['showall'])) :
$args = array('hide_empty' => 0);
else :
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$per_page = 80;
$offset = ($page - 1) * $per_page;
$args = array('number' => $per_page, 'offset' => $offset, 'hide_empty' => 0);
endif;
$taxonomy = 'post_tag';
$tax_terms = get_terms($taxonomy, $args);
echo '';
foreach ($tax_terms as $tax_term) {
echo '' . '<li style="float:left"><a style="color:#fff;" href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf(
__("View all posts in %s"),
$tax_term->name
) . '" ' . '>' . $tax_term->name . '</a> </li>';
}
echo ''; ?><br><br>
<?php
$the_query = new Wp_Query(array(
'cat' => $cat,
'orderby' => 'id',
'order' => 'DESC',
'paged' => get_query_var('paged', 1)
)); ?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
主体内容
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
分页按钮:
<div id="aid" style="text-align: center;margin:19px;">
<?php echo paginate_links(array(
'total' => $the_query->max_num_pages
)) ?>
</div>
<?php
if (is_tag()) {
$tagName = single_tag_title('', false);
$tagObject = get_term_by('name', $tagName, 'post_tag');
$tagID = $tagObject->term_id;
} ?>
<?php
$the_query = new Wp_Query(array(
'tag_id' => $tagID,
'orderby' => 'id',
'order' => 'DESC',
'posts_per_page' => -1
)); ?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
主体内容
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
相关推荐
© 2020 asciim码
人生就是一场修行