WordPress - posted_on not displaying (PHP)

心不动则不痛 提交于 2019-12-12 05:08:18

问题


I have been working on a WP theme (based on twentyeleven) for a while that has a spotlight (featured) area for sticky posts: http://www.designated.net.au/testbed/wordpress/

The problem I am having is that the posted_on declaration does not display for the sticky post. I am a total noob when it comes to PHP so I don't really know what I'm doing.

To feature the sticky posts I used this guide: http://line25.com/tutorials/how-to-create-a-featured-post-layout-in-wordpress

But I changed the display of the post to use the code from content.php. So I am using the following:

<?php if ( 'post' == get_post_type() ) : ?>
<div class="entry-meta">
<?php twentyeleven_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif; ?>

That is the part that doesn't display.

I'm happy to supply more code if you need me to.


回答1:


If you need to display the post date, use <?php echo get_the_date(); ?>

You can display the date in any format. Check this Codex for Formatting Date and Time




回答2:


Have you tried using get_post_type( $post->ID ).




回答3:


I figured it out. It was a problem with the CSS. For some reason it was set to absolute with zero left and top.



来源:https://stackoverflow.com/questions/12380813/wordpress-posted-on-not-displaying-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!