The tag has no wiki summary.

learn more… | top users | synonyms

12
votes
5answers
628 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
91 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
2answers
1k 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
945 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
338 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 ...
1
vote
1answer
852 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
76 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
122 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
261 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
93 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
106 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
1answer
50 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 ...
0
votes
2answers
295 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
1answer
28 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 ...
0
votes
2answers
46 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
299 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
84 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
3answers
1k 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 ...
0
votes
1answer
129 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
1answer
158 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
3answers
130 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
254 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
1k 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
1k 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
100 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
411 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
655 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
84 views

Get categories list with category name in custom WP_List_Table class

Im building a plugin and i made custom wp_list_table class to suit my needs and display items with native wordpress look. The problem is that i can't get to list categories with categories names. I ...
0
votes
1answer
44 views

different post-class when template is loaded via ajax

my event-item.php <?php /** * The event template */ ?> <li> <article id="event-<?php the_ID(); ?>" <?php echo event_canceled($post) ? post_class('wrapper canceled') : ...
0
votes
1answer
38 views

Apply Post Class to Custom Post Type

I am trying to add specific CSS post classes to the services custom post type. However, when I apply this function to the post class filter, it applies the function to all post types. My goal is to ...
0
votes
1answer
491 views

How to add class to anchor using wp_nav_menu

Sorry if my post duplicate but i can't find best solution for my problem. I'm newbie on develop WP theme. Now i'd like to add class to current li and last li, but i don't know how to do? Hope someone ...
0
votes
1answer
160 views

How to get category names in post_class?

I have this class for my posts: <?php post_class( 'entry-image' ); ?> I want to add the category names to get isotope work, i followed this guide ...
0
votes
1answer
313 views

How to use post_class function?

I would like to use this function, but I don't know correctly what is the perfect way.. The code: <li id="post-<?php the_ID(); ?>" <?php post_class(get_the_content() == "" ? ...
0
votes
1answer
74 views

Add a class to post_class if more than one post shares same meta_value_num

I would like to be able to add a class such as .samedate to posts that share the same meta_value_num from a custom meta box. So for example: Say two posts share the same custom meta box value for a ...
0
votes
1answer
64 views

Enclose title within a div?

I'm using this code to display a page within my front page. I would like to learn how to add a div / spacer to isolate the page title... If I try to add a div class within the php code then it throws ...
0
votes
1answer
980 views

add filter to wp_list_categories and query if used to list tax-terms?

this is probably a confusing title of my question, but it's exactly what's describing my problem best. I want to add the category-slug as classname to my wp_list_categories() output. I found a really ...
0
votes
1answer
736 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
0answers
30 views

How to remove a class from a post_image div?

So for a post i know how to remove a class by using function remove_class( $classes ) { $classes = array_diff($classes, array('hentry')); return $classes; } ...
0
votes
0answers
19 views

Styling every second Post differently? [duplicate]

I wanted to style every second post inside of a query post and I found a solution which nearly works. the thing is: it outputs just two posts (older ones will be igrnored) but i want to output ALL ...
0
votes
2answers
716 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 ...
0
votes
1answer
53 views

How do I create a sticky sidebar?

How do I give the three posts here different div classes? I'm working with twitter bootstrap and I'm trying to give the first post and the last one <?php query_posts('category_name=Menucard'); ...
0
votes
1answer
661 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 ...
0
votes
1answer
293 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 ...
0
votes
1answer
177 views

post_class remove tag- or category- from slug

I've got this in my theme <article <?php post_class('archiveMain'); ?>> But for tags and categories it adds tag- or category- before the slug, any way to remove that? Example: ...