The tag has no usage guidance.

learn more… | top users | synonyms

13
votes
5answers
1k views

How to mark every 3rd post

I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is ...
4
votes
1answer
436 views

Category as Class for Custom Post Type

I've only just realised that custom post types don't appear to output the category as a class in the loop, via post_class and I wonder if anyone can suggest a work around. Is this something that ...
2
votes
3answers
2k views

Alternate post_class on each post

I need to have an alternating (even, odd...) class on posts to provide alternate highlights on a column. The best thing would be to attach this to the post_class() so that it's on every instance of ...
2
votes
2answers
643 views

Wordpress Loop - Style rows of posts differently

I am trying to adapt the Wordpress loop to style posts differently in rows that get infinitely smaller until all posts are displayed The concept here is to display posts in rows first row 1 post ...
2
votes
2answers
1k views

Get parent category class in post_class()

I am trying to add the parent category class in post_class() of some posts from one of my subcatgories. I have an advanved theme so I need to style all the posts from the parent cateogry using it's ...
2
votes
2answers
3k views

Add class to the items in wp_list_pages

I just want to add a class for the active page in the wp_list_pages().Is it possible? If so can I provide a particular class for a active page. Here is my code for listing the parent page and its ...
1
vote
1answer
1k views

Duplicate attribute class causing site validation error

The following bit of code results in a duplicate attribute site validation error. This template script: <div class="clearfix" <?php post_class() ?>> produces this source output: ...
1
vote
1answer
558 views

Adding body class when post contains a specific shortcode

Simple shortcode function : function my_shortcode_function($atts,$content=null){ // Do something return $content; } add_shortcode('my_shortcode','my_shortcode_function'); I wonder how to add ...
1
vote
3answers
6k views

current-menu-item class for custom post type parent

Im having a problem with my menu and custom post type. I have a custom post type of "services". I have created new page for it called Services. On that page Im displaying a list of all the post from ...
1
vote
1answer
199 views

Theme Check: Could not find post_class

I've inherited a theme from a another developer that I've re-styled for a client. We're just about finished, but I thought I'd run it through the Theme-Check plug-in to see if there's any errors or ...
1
vote
1answer
50 views

Is post_class(); going to slow Wordpress page speed

I just have a general question about the post_class(); function. As it gets category and tag classes relating to a post, is it database/server intensive to call this on a category page, or even a ...
1
vote
1answer
31 views

WordPress post arrangement using post_class

I want to create post layout in the following way: +--------------------+ | 1 Full Width Post | +----------+---------+ | 2 | 3 | +--------------------+ | 4 Full Width Post | ...
1
vote
2answers
784 views

Wordpress: How to use post_class() in an echo

I am working on a foreach loop in Wordpress and want to add 'post_class()' to a div within it. Currently the code looks like this: if ( is_array( $posts ) && !empty( $posts ) ) { echo ...
1
vote
1answer
253 views

Add a class to post title if a link ends with a certain extension

I am using a Page Links To plugin that allows me to link the post title to an external web page, rather than to the content of the post. And I link some of the post titles to external pages, and ...
1
vote
1answer
434 views

Add Post Tags to Body Class

Want to add post tag name to body class - I am successful in using the code below to add category to body class - //adds new body class for post category add_filter('body_class', ...
1
vote
1answer
334 views

Output terms to post_class()

I am trying to output all terms attached to a specific post (including custom taxonomy terms) as CSS classes applied to a DIV Something like that : <div <?php post_class('class-name'); ...
1
vote
1answer
2k views

Child Pages Loop

If anyone can help that'd be great. I've found a snippet of code that I've used which is pretty much doing what I want it to do, which lists out subpages of the parent, adds a thumbnail if there is ...
1
vote
1answer
845 views

If Loop has odd number of posts on last page Custom style for last post in it

My loop displays posts in two columns using this php <?php if (have_posts()): while (have_posts()) : the_post(); $count++; ?> <?php if ($count == 1) : ?> <div ...
1
vote
1answer
118 views

How to make classes for posts?

Thanks in advance. I'd like to have posts with different colored borders and headers. It would be nice to choose a category of the post (red, blue, black, etc.) and have it change the class for that ...
1
vote
0answers
39 views

How to load post_class() locally

I'm using post_class() function to retrieve WordPress provided classes for a post. I've successfully implemented an AJAX powered "Favorite Post" functionality to each and every post, and I'm changing ...
1
vote
1answer
195 views

Indirect modification of overloaded property WP_Post::$classes has no effect

I'm working on a child theme and while everything works the Walker_Nav_Menu and Walker classes are causing all the fuss. My parent theme overrides Walker_Nav_Menu as below: if ( ! class_exists( ...
1
vote
1answer
66 views

How to assign classes to all elements?

Is it possible to assign classes to elements of certain type? For example, all paragraphs in the post body or comment body should have class="paragraph", all unordered lists in post body should have ...
1
vote
3answers
25 views

Change Post Class function

I wish to change/remove parts of the automatic post class function that's built in to wordpress, lets say when i make a post, the html code generated looks like this: <div id="post-106" ...
0
votes
2answers
655 views

Odd/even class on article tag

I am using the article tag with the following code: <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix span4 '); ?> role="article"> </article> and I would like ...
0
votes
2answers
226 views

post_class output in wrong area?

Trying this in my functions file. There is actually a lot more to this function than I am showing, but this is the important part that is messed up. function xyz_loop() { $defaults = array ( ...
0
votes
2answers
48 views

Post classes in the loop are being changed in certain themes

Certain themes don't use the default post class structure in the loop ie <div class="post-100 post type-post status-publish format-standard hentry category-uncategorized"> Spacing.ca, for ...
0
votes
2answers
927 views

How do I add a custom body class for a specific page ID?

I have added this code to my child theme's functions.php file and use the new class but it styles the entire site, not the page I added to the code. What am I doing wrong? ...
0
votes
3answers
129 views

Need help “sanitizing” a custom function that pulls category slug into body class

Not sure if "sanitizing" is really the correct phrase to use for this but it was the best one I could think of...anyways, here is the problem: My function works great like so... // add category id ...
0
votes
1answer
49 views

How to change “post_class()” for a custom post type?

I am trying to keep the classes the exact same on my normal (blog) posts, and a custom post type I have called "locations". When I post a "normal post" I get the following classes: class="post-# ...
0
votes
1answer
91 views

How to specify a class added to my gallery

I would like to add a class to my gallery short code, this is how I have added my class: [gallery class="small" columns="2" ids="350,349,302,305"]. Now the confusion comes in, I am not sure how to ...
0
votes
1answer
216 views

post_class() breaks out of formatting. . . extra markup also generated

Hoping Im just running into something easy Here's the scenario, I've created a function called tr_get_post_image_tplt that spits out the post thumbnail (or custom size) for the post being called. Im ...
0
votes
1answer
67 views

What Generated Classes and IDs That Is Always Used On All Themes?

Just wondering if there is a way to get a complete list of wordpress generated css classes and ids that is always automatically assigned to any themes. I've read here, but it seem not list them ...
0
votes
2answers
201 views

post_class not working with css

through the codex I read about how to use the post_class() function to create a css hook for styling the content. Here is the code I have, PHP: <li class="<?php post_class();?>"> ...
0
votes
3answers
265 views

Using post_class to style posts indivdually

I have a homepage on which I want to display the latest post different from the other posts. I haven't used post_class and I am not sure how to. Would I be able to achieve what I want using ...
0
votes
1answer
745 views

Add $values to post_class()

This must be pretty simple, but it is eluding me. I need to add several classes to post_class() http://codex.wordpress.org/Function_Reference/post_class I can add one class in a page template, as ...
0
votes
1answer
2k views

How can I make wp_list_categories output li with category-slug as class, for its children?

Simply put, I'd like to change the wp_list_categories output from this: <li class="cat-item cat-item-1"><a href="http://mysite.com/category/articles">Articles</a></li> ...
0
votes
2answers
3k views

adding a custom css class to post

essentially I need to be able to add a class to a post when it show in the list (say index.php) so when in the back end you can say oneCol, twoCol, threeCol and it will then output this within the ...
0
votes
1answer
123 views

How can i remove the posts category class names from body_class

I have 2 categories, just to make an easy example, Cars and Bikes. I have a post that fits both of the category. If i visit the Cars category, the body_class looks like this: "archive category ...
0
votes
1answer
1k views

CSS class on last post in loop ( custom query )

I have been using this question to try to do this but I am having some difficutlty. I have a custom post type, media, and I am working on the archive-media.php template. I have it partially working ...
0
votes
1answer
571 views

Adding post_class into functions.php query

Obvious newbie question I'm sure. Working on a friend's site and trying to figure out how to add post_class to a query. Just adding works fine and adds the div, but I don't know how to get it to run ...
0
votes
2answers
895 views

List of Body Classes Generated by body_class()

Does anyone know where I can get a list of all the body classes generated by body_class() for every sections and every conditions, including custom post-types, etc.? For example, for a search result ...
0
votes
1answer
27 views

How to edit the styles for the table of pages/post listed in the admin when you click on pages/posts?

It seems that some of the css on the table that shows the list of all the pages adversely reacts with one of my plugins, which adds a bunch of columns to the table. I'm pretty sure this is edit.php. ...
0
votes
1answer
27 views

How can I add a class to particular paragraphs in my post?

The effect I'm looking for in the end is to have the first line in some paragraphs bolded. These would be the first paragraph of each section in my post. This kind of effect is used on this ...
0
votes
2answers
77 views

Where should I use post_class()?

I am trying to learn WP Theme development. And as I have understod it is important to use "post_class()" since plugins may need to use it. But what I not understand is where I should use it? Should ...
0
votes
2answers
179 views

How to style posts selecting a CSS post_class (added through custom_fields?)?

Here is what I tried and couldn't reach it. Maybe I need a whole different approach? 1) I created a custom field in a post, called post-class and inserted the value cita-flow800000 (weird class name ...
0
votes
1answer
218 views

Every second post different class in blog view

To assign different classes to every 2nd post in blog view in WordPress adding this code into function.php was suggested as solution. Most people claim it is helpful, but to me it just adds odd at the ...
0
votes
2answers
2k views

Adding class to featured image

I have specified a loop to show featured images for my custom post type and wish to add a img-responsive class from bootstrap to my featured image. How can I do this? Thanks! Code: <div ...
0
votes
1answer
77 views

Add a class to post if it has been recently updated

I'm trying to add 'updated recently' after the post title. I've discovered some code which works but because of plugins and some theme coding it affects numerous instances of the_title that it ...
0
votes
1answer
205 views

Microformats in a single post - layout conflict

WordPress uses microformats, for example, when we use the function post_class() in the DIV containing the article. It automatically includes the class called hentry, which is used in microformats. ...
0
votes
1answer
68 views

wordpress add field to post_class

I need to add a custom field to my article post but not sure how to add an additional class to it. Currently the classes get pulled through like this <?php post_class($classes); ?>. However I ...