Display Wordpress Post Number on Single Page with post ID

94

You can see it work throughout this wordpress blog, to the right you see DCE Article 94. Notice you can select the number as text. The number is pulled from the post on every single page by placing this line of code in your wordpress single.php template page.

<?php the_ID(); ?>

Note: When using this line of code be sure it is between these two lines of code in your single.php page

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php endwhile; else: ?>

I place the code in its own div with a background image to create the illusion of unity. I use margins to move the number to the right spot of the image. My CSS and Code looks like this.

<style>
#page_number_id_spawn { float:left; text-align:right; margin-top:240px; width:135px; color:#900; font-size:30px; font-family:Georgia, 'Times New Roman', Times, serif;}</style>

<div id="page_number_id_spawn"><?php the_ID(); ?></div>

0 comments ↓

If you found this post useful click the share this button. Contribute below by adding a comment, no registration is required.


There are no comments yet...Kick things off by filling out the form below.

Leave a Comment