forked from collins401/Bytecats
/
index.php
53 lines (44 loc) · 1.67 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php get_header(); ?>
<div class="grid-3-4 main" role="main">
<!-- section -->
<section id="content">
<h2>关于我们</h2>
<!-- 根据页面ID截取简介长度 -->
<?php
$page_id = 2;
$content = get_post($page_id)->post_content;
$trimmed_content = wp_trim_words( $content, 250, '<a href="'. get_permalink($page_id) .'" class="more-read"> 阅读全文→</a>' );
echo '<P>'.$trimmed_content.'</P>';
?>
<!-- 获取最新4个产品 -->
<h2>产品推荐</h2>
<ul class="index-pro row">
<?php
$args = array('post_type' => 'product', 'showposts' => 4, );
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();?>
<li class="grid-1-4 col-1-2">
<a href="<?php the_permalink(); ?>"><?php echo post_thumbnail('200','200'); ?></a>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</li>
<?php endwhile; wp_reset_query();} ?>
</ul>
<h2>新闻资讯</h2>
<!-- 获取最新5篇文章 -->
<ul class="index-news">
<?php
$args = array('post_type' => 'post', 'showposts' => 5, );
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> [<?php the_time('Y-m-d'); ?>]
</li>
<?php endwhile; wp_reset_query();} ?>
</ul>
</section>
<!-- /section -->
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>