adsense

How to Display Featured Posts in WordPress





1. Open the 'index.php' file of your current WordPress theme in a code editor. WordPress calls its templates 'themes,' and you can find their files in the following location:/site-name/wp-content/themes/theme-name/Change 'site-name' to whatever you named your main WordPress folder and change 'theme-name' to the name of the theme you want to edit.
2. Copy and paste the contents of 'index.php' into a new file and save it as 'home.php'. When WordPress finds a 'home.php' file in a theme folder, it uses that file to display the first page of your blog if the blog is your home page. This is in contrast to the 'front-page.php' WordPress uses to display contents of a static home page.

3. Find the WordPress loop in the code of 'home.php'. It starts like this:
Sometimes the loop is all on one line, but sometimes you will see it broken up. Add a few blank spaces above the loop and add this code:



The code above sets a query, begins a new loop, ends the loop and then resets the query. You must reset the query to avoid effecting the second loop.
4. Write your query between the parantheses after 'query_posts'. You need to query featured posts, so use the following code:
'Featured')); ?>Save the file and upload it to your server.
5. Log into the WordPress dashboard and add the category name 'Featured' to all featured posts. Update them and then visit your website to see the results. Featured posts will display first on the first page of your blog, and then all posts will display beneath them.

Comments

0 Responses to "How to Display Featured Posts in WordPress"

Post a Comment

Popular Posts

About