WordPress - posted_on not displaying (PHP)

2019-08-29 05:07发布

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.

3条回答
Explosion°爆炸
2楼-- · 2019-08-29 05:27

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

查看更多
三岁会撩人
3楼-- · 2019-08-29 05:40

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

查看更多
家丑人穷心不美
4楼-- · 2019-08-29 05:53

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

查看更多
登录 后发表回答