wordpress主题

时间:2010-07-27 05:49:07

标签: wordpress

我正在创建wordpress主题并面临一个小问题。

在我的主题中,有页面, 我想要显示页面的标题,如“关于”,“博客” 我该怎么做。

第二,我想在博客页面下显示所有帖子。即使我为博客创建了一个模板,但不幸的是,它没有发生。

感谢您的帮助。

6 个答案:

答案 0 :(得分:2)

你需要创建一个循环,以便wordpress可以查看是否有任何内容,如果有,然后显示它

所以关于页面等的page.php将是:

<?php if (have_posts()) : while (have_posts()) : the_post();?>
<h1><?php the_title();?></h1><!--the title-->
<br />
<?php the_content();?><!--the content-->
<?php endwhile; endif;?>

答案 1 :(得分:1)

1st:使用<?php the_title(); ?>显示pagetitle。

第二:要显示完整帖子,请使用:<?php the_content(); ?>

答案 2 :(得分:0)

/*
* Template Name: Blog
*/

  //to show title

    the_title();


  //to show the post

  if (have_posts()) : while (have_posts()) : the_post();

  the_content();<!--the content-->

  endwhile; endif;

根据模板页面中的要求使用上述代码。

答案 3 :(得分:0)

<强> 1。显示标题

只需添加<?php the_title(); ?>

<强> 2。显示博客帖子。 我写了一些代码来展示页面中的所有博客帖子, 即时通讯使用查询帖子,让它:

    if (is_page($your_page_id)) { ?>
    <div id="primary" class="content-area">
    <div id="content" class="site-content">
    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for paging
    $args = array('paged' => $paged);
    query_posts($args); // query posts
    if (have_posts()) :
        while (have_posts()) : the_post();
        get_template_part( 'content', get_post_format() ); // This code will display your posts
        endwhile;
        your_content_nav( 'nav-below' );
    endif;
    wp_reset_query(); // please, add this function to reset the query
    ?>         
    </div><!-- #content .site-content -->
    </div>
    } else {
 // normal page here
}

答案 4 :(得分:0)

如果您想创建博客和关于网页。您必须通过wordpress创建页面。 因此,请点击 wordpress 页面button,然后创建页面并根据您的想法设置sub-menus ...

对于您的第二个问题,答案是转到最新页面选择选项并为您的主页/索引/第一个屏幕选择静态页面,然后在页面下方选项中选择您要移动您的菜单最新的帖子内容......

答案 5 :(得分:0)

如果您想在页面中显示帖子,则需要先为帖子创建类别,然后对每个帖子进行分类。之后,您可以根据帖子类别创建页面。现在,要在这些页面上发布帖子,您可以使用我在答案HERE中发布的get_posts()方法。