如何进入主页?

时间:2015-12-12 08:21:09

标签: wordpress wordpress-theming

大家好我是wordpress的新手,我使用主题wordpress基础,当我发帖时,在我的主页上看不到帖子,我试着在我的主页上写代码来发帖但是还是看不到帖子,我该怎么办,这是我的代码:

page.php文件

<?php
/*
 *  Template Name: Page - Events Page
 */
?>
<?php get_header(); ?>
<div id="content-events">
    <div id="head-event"><h3>EVENTS</h3></div>
    <div id="main-event">

<?php
$args = array(
    'cat' => '5',
    'post_type' => 'post',
    'posts_per_page' => 8,
    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
);
query_posts($args);
while (have_posts()) : the_post(); ?>
  <div id="part-event">
                            <div id="entry-thumbnail">
                                    <?php the_post_thumbnail(); ?>

                            </div>
                            <div id="event-dess">
                            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                <p>
                                    <?php 
                                    $content = get_the_content();
                                    $content = strip_tags($content);
                                    echo substr($content,0,300)." . . . ";
                                    ?>
                                </p>
                                <div id="read-more"><a href="<?php the_permalink(); ?>">Read More</a></div>
                            </div>

                    </div>
                 <div id="line-bottom"></div>
  <?php
endwhile;

?>
    </div>
 <div id="page-gina">
 <?php 
 wp_pagenavi();
 wp_reset_query();  // Restore global post data
 ?>
 </div>
</div>
<?php get_footer(); ?>

请帮帮我!!!

1 个答案:

答案 0 :(得分:1)

<?php
/*Template Name: homepage template
*/
get_header();
?>
<?php
                    $args = array(
                    'cat' => '3',
                    'post_type' => 'post',
                    'posts_per_page' => 8,
                    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
                    );
                    query_posts($args);
                    while (have_posts()) : the_post(); ?>
                    <div id="part-event">
                        <div id="entry-thumbnail">
                            <?php the_post_thumbnail(); ?>

                        </div>
                        <div id="event-dess">
                            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                            <p>
                            <?php 
                            $content = get_the_content();
                            $content = strip_tags($content);
                            echo substr($content,0,300)." . . . ";
                            ?>
                            </p>
                            <div id="read-more"><a href="<?php the_permalink(); ?>">Read More</a></div>
                        </div>

                    </div>
                    <div id="line-bottom"></div>
                    <?php
                    endwhile;

                    ?>
                </div>
<?php get_footer(); ?>

注意:在仪表板中, i)创建名为Home的页面, ii)显示相同页面右侧模板列表分配主页模板, ii)在设置 - &gt;阅读 - &gt;分配首页。