2013-12-07 66 views
0

我正在尝试创建一个自定义WordPress页面,该页面将只包含指向我所有职位的链接,分为4列。我也使用WordPress的Bootstrap。用邮政标题创建一个自定义WordPress页面

我创建了php文件,使用她的页面属性创建了一个新页面,但帖子标题不显示。

这是我使用的代码:

<?php 
/** 
* The template used for displaying page content in questions.php 
* 
* @package fellasladies 
*/ 
?> 

<?php 

<article id="post-<?php the_ID(); ?>" <?php post_class('col-md-4 col-sm-4 pbox'); ?>> 
    <header class="entry-header"> 
     <h1 class="entry-title"><?php the_title(); ?></h1> 
    </header><!-- .entry-header --> 

    <div class="entry-content"> 
     <?php the_content(); ?> 
     <?php 
      wp_link_pages(array(
       'before' => '<div class="page-links">' . __('Pages:', 'fellasladies'), 
       'after' => '</div>', 
      )); 
     ?> 
    </div><!-- .entry-content --> 
    <?php edit_post_link(__('Edit', 'fellasladies'), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>'); ?> 
</article><!-- #post-## --> 

我真的很感谢你的帮助!谢谢

回答

1

我鼓励你阅读关于Wordpress Codex的Page Templates,这可以帮助你很多!

页面是WordPress的内置邮政类型之一。你可能会希望你的大部分网站页面看起来都差不多。但是,有时候,您可能需要一个特定的页面或一组页面来显示或行为不同。这很容易用页面模板完成。

看来你有一个<?php没用。您也没有定义您的模板名称,需要

+0

请您总结该文章的主要发现? –

+0

页面名称显示在页面属性下,因此我选择了它。但是,当指向该页面时,不会显示所描述的帖子标题。 –

1

您需要首先创建一个Query,它用您想要迭代的帖子填充数组。阅读WordPress中的get_posts()函数。

下面是一个例子。请注意,我们不能使用旨在在循环中使用的函数,例如the_title()或the_content()。我们必须为每次迭代指定post_id。我们不应该修改这种情况下的主要查询。

// the arguments for the get_posts() function 
$args = array(
    'post_type' => 'post', // get posts int he "post" post_type 
    'posts_per_page' => -1 // this means the array will be filled with all posts 
); 
$my_posts = get_posts($args); 

// now we'll iterate the posts 
foreach ($my_posts as $p) { 
    // a title 
    echo get_the_title($p->ID); 
    // the link 
    echo get_permalink($p->ID); 
    // a custom field value 
    echo get_post_meta($p->ID,'custom_field_key',true); 
} 

在每次迭代中发生什么取决于您。

祝你好运! :)

+0

仍然没有工作,但感谢张贴回复在这里:( –

相关问题