WordPress - posted_on not displaying (PHP)

2019-08-29 05:17发布

问题:

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.