adsense

How to Make a WordPress Post Sticky to the Top





1. Navigate to your WordPress folder. Open 'WP-Content' and then 'themes.' Within that folder, find the folder named for the theme you wish to edit. Open that folder and look for 'Index.PHP' and 'Home.PHP.' If you do not have a Home.PHP file, that is OK. Open those files in a code editor like Notepad , BBEdit or jEdit.
2. Locate the main
or
tag that surrounds the entire blog post. This tag often contains a class named 'post' or something similar to that. After that tag, you should see code for the post title and then the content. Here is an example:


'>






3. Add the post_class() function to the
or
tag. You only need this code in the tag that wraps around the whole post. Here is an example of a
tag modified to include the post_class() function:
>The post_class() function generates multiple class names for every post, including the class name you need for sticky posts, 'sticky.'
4. Open the 'style.css' file for your theme, and add the following CSS code:.sticky {background-color: #f4f583;}This code gives all stickied posts a light yellow background color, but you can change the CSS code to include any styles you want. For example, you can add a thick, blue border around the posts, or you can change the color of the text.
5. Log in to the WordPress dashboard. Navigate to 'Posts.' Click a post you want to make sticky and then click the 'Edit' link next to 'Visibility' in the 'Publish' box. Tick the box next to 'Stick this post...' to set the post to sticky, and then click 'OK.' Click the blue 'Update' button to save changes.

Comments

0 Responses to "How to Make a WordPress Post Sticky to the Top"

Post a Comment

Popular Posts

About