The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
20 views

post_type_exists keeps returning false

I have a little helper class for registering new custom post types. However, it seems it is registering the custom post type on each page load. I put in a small check for this: if( ! ...
0
votes
1answer
26 views

Different styles for categories - need to edit a plugin

I'm using a plugin to add recent posts to home page and I am using different styles for the categories. I have the different styles working on the blog page but not on the posts output from the ...
0
votes
2answers
23 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
32 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
0answers
15 views

Moving Plugin Code into a Theme - Class Declaration - what hook should I use to create new instance?

I'm planning on moving a Plugin Inside a Theme I'm creating. The Plugin currently utilizes a Class to declare and set up the Custom Post Type and all of the other functionality of the plugin itself. ...
0
votes
1answer
42 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. ...
1
vote
2answers
80 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 ...
0
votes
0answers
121 views

How make modular WP plugin based on OOP?

For example I have "my-plugin" plugin created using class: class My_Plugin { public function __construct() { } /** * Other code where I creating plugins admin pagec etc. */ } ...
0
votes
1answer
29 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 ...
0
votes
2answers
75 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
1answer
1k views

How to add class or id to shortcode HTML elements?

I have a row elements and 3 columns inside : [row] [one_third]1[/one_third] [one_third]2[/one_third] [one_third]3[/one_third] [/row] How can I add a custom class or id to [row] element ? I need to ...
0
votes
1answer
48 views

Wordpress Tags in class

I have added tags to my Custom Post Type. Now I want to use them to create a isotope portfolio, I can load all tags with this code: <?php $args = array( 'post_type' => 'portfolio', ...
0
votes
1answer
84 views

Help with output of post classes using apply_filters

I’m new to scripting, this is a plugin I'd like to modify to output post classes. When I try using: apply_filters( 'post_class', $page->post_class ) it only outputs array=" ". Do I need an ...
1
vote
1answer
105 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
1answer
235 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 ...
4
votes
1answer
211 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 ...
0
votes
0answers
64 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
1answer
82 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
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
1answer
51 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
3answers
3k 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
1k 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
2answers
1k 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
59 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'); ...
1
vote
1answer
55 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
1answer
160 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'); ...
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
3answers
175 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
2answers
463 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? ...
1
vote
1answer
145 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 ...
0
votes
1answer
223 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
2answers
473 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
602 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
1k 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
121 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 ...
0
votes
1answer
97 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
426 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
3answers
101 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
230 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: ...
0
votes
1answer
72 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
374 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> ...
2
votes
2answers
407 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 ...
0
votes
2answers
2k 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
2answers
180 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
105 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
185 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
1k 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
868 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 ...
12
votes
5answers
812 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 ...