Here is a simple solution of how to display one full post on your WordPress homepage and sections on other pages such as archives page and categories page.
Enter the more tag in your posts at the point in which you prefer. The more tag looks like this.
Note: Do not put any whitespace between the tag otherwise it will not work.
Go to the settings section in your admin and then to the reading section. Change the blog pages shown at most setting to display the number of posts per page to suit your requirements.
Add the following code below get_header() at the top of your index.php page in your theme template.
<?php if (is_home()) {$page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=1&amp;paged=$page"); } ?>
Whilst you have your index.php open look for the_content(), and make sure it is empty like this.
<?php the_content(); ?>
Then go to your archives.php and/or categories.php (if you have one) and enter the following.
<?php the_content('Read More'); ?>
You can change this to suit your requirements
That’s it you should now have one post on your main blog page and small sections of posts on your others. Just don’t forget to add the more tags to your posts!
The more tag is supposed to be ignored on the homepage if this method doesn’t work then we will set it manually.
In index.php
Declare the global $more underneath get header().
<?php global $more;?>
Then add the following above the_content();
$more = 1;
For further reading about the more tag visit customising the read more and Template_Tags/query posts on the WordPress Codex.
Welcome to Hot Web Dev November 2024, featuring the latest technology and web development news.… Read More
Welcome to Hot Web Dev October 2024, featuring the latest technology and web development news.… Read More
In this tutorial, you’ll build a fun and interactive guessing game using Svelte 5, the… Read More
Welcome to Hot Web Dev September 2024, featuring the latest technology and web development news.… Read More
The JavaScript guessing game tutorial is a simple beginner's project. It features modern JavaScript syntax… Read More
If you have been following the monthly Hot Web Dev magazine you will find the… Read More