Skip to content
Advertisement

How can I add my custom css class to all existing posts in wordpress? [closed]

I am reworking my theme on wordpress and I already have a lot of existing posts, each post has its standard class made by a wordpress and I would like to add my custom class to these all posts depending on row in database.

All I want to know is how to exactly add any css class to existing posts?

Advertisement

Answer

You can use the plugin “Post/Page specific custom CSS” to add custom css to any post or page.

Update: I found a solution to this problem. Of course, this solution may be a little complicated. But with this method, you can assign a style to several specific posts. First, you must find the post ID from the database or with the below method.

  1. Click to edit your post or page.
  2. In your browser URL bar at the top of this edit screen, you will see something like this where the id: …/wp-admin/post.php?post=447&action=edit
  3. In the example above, there are 477 post IDs.

Once the post IDs are found, follow the example below.

/*first use .postid- and if it does not work then use .post- */

.postid-477 h4 , .postid-300 h4 , .postid-256 h4 {
     font-family:tahoma;
     color: #77a13b;
     size: 28px;

}

or

.post-477 h4, .post-300 h4 , .post-256 h4 {
     font-family:tahoma;
     color: #77a13b;
     size: 28px;

}
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement