Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [post-class]

The tag has no usage guidance.

-1
votes
1answer
19 views

PHP Use Declared array Variable inside already Declared Array

i have created one class in which i declared public associative array. class test{ public $basicCols= array( array('title'=>'KEY', 'field'=>'slug','options'=>$optList), array('...
1
vote
2answers
57 views

Remove Extra Classes from Post Title

I want to remove tag, category classes from Post Titles of my WordPress blog. On the frontend, Wordpress generates extra classes for every single article title. For Example, this article, has these ...
0
votes
2answers
342 views

Remove classes from post_class()

I am trying to tidy up the post_class function. I've managed to remove "hentry" class using the filter below, but I would also like to remove the "post-id", "type-" and "status-" classes as well. How ...
4
votes
2answers
1k views

How to add classes to post_class?

In the following code I would like to remove the div that wrap all the code and pass its class to article, but I do not know how to pass the variable $termString inside the post_class. Can anybody ...
0
votes
1answer
130 views

Adding Filter to Homepage only

I want to execute the following code only on the homepage for the default post loop. I added this to the functions.php, but it doesn't work. It works and adds the according altering classes if I use ...
3
votes
2answers
459 views

Add a different class name to each sticky post?

I am trying to set up a featured content section of my blog. This will contain two sticky posts. I have a custom loop which will only display the two sticky posts, in the loop I then get a content-...
0
votes
0answers
292 views

Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?

I have a couple of custom post types (course and assignment) for an custom LMS plugin that I'm building. The course CPT represents content that is produced internally by the company. The assignment ...
0
votes
1answer
44 views

How can i show post_class() within output loop?

I am trying to use show post_class() within $output loop.Though i tried it different way i failed. Here is my codes $output = '<div '; post_class('blog-list-vertical-content'); $output .= '" id=' ...
0
votes
2answers
176 views

How to add padding between posts

Ultimately, I'm really confused on how exactly you create a single class that affects each post in a static home page "recent post" type content area. I want to essentially have it where there's a ...
3
votes
1answer
4k views

Remove and add class with body_class() function

I want to remove the default body class on the theme and add a new class. I use this code to do this: //REMOVE / ADD HOME CLASS FROM BODY add_filter('body_class', function (array $classes) { ...
0
votes
1answer
111 views

get_post_class not working properly

I have a plugin on my WordPress site that lists the most visited pages. I recently realized that it was displaying certain pages that I don't want to display. I also want to be able to disable pages ...
0
votes
1answer
60 views

How to add post classes?

I can use post_class() to echo all classes for a post. How can I output only the category-ID as a class, and how can I include this while using heredoc string syntax? I got this function in which I ...
0
votes
2answers
848 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
40 views

Highlight a Post on archive page if it has a new comment?

I have been searching for a solution to highlight a post if it has a new comment but there is no plugin/forum answer about this. Basically I have a custom post type listings on a page. I want to add ...
0
votes
1answer
915 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 Bloomberg....
1
vote
2answers
377 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" class="...
0
votes
1answer
1k 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-# ...
6
votes
1answer
5k 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 ...
1
vote
0answers
96 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 ...
0
votes
2answers
446 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 ...
2
votes
1answer
1k 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( '...
0
votes
1answer
474 views

Custom query with post_class filter using current_post not working

I have a new WP_Query on my archive page. I also have a post_class filter conditionally adding a class of first so I can display them in rows of 3 reliably. This is the post_class filter function ...
1
vote
1answer
82 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 ...
0
votes
1answer
1k views

Wordpress call post-ID in jquery

I explain the situation I'm having here: On my home page, I have a list of post being display. I've code to have like a modal box to share this post. Basically, on each post you have a button share. ...
1
vote
1answer
39 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 | +----------...
0
votes
1answer
51 views

Method 'post_title' not found in class.

I'm running some code through phpStorm and am getting an error: Method 'post_title' not found in class. at this line: echo $post->post_title(); Is that phpStorm getting things wrong or am I ...
0
votes
2answers
600 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
668 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
1answer
82 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
1answer
563 views

Post Class for Custom Taxonomy Error

I'm getting two errors with the following code. I'm essentially trying to go through all the custom taxonomies and add them to the post class. Notice: Array to string conversion in /...
0
votes
1answer
849 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( ! post_type_exists(...
0
votes
1answer
110 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 ...
1
vote
2answers
9k 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 class=...
0
votes
1answer
103 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 shouldn'...
0
votes
1answer
279 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. ...
2
votes
2answers
3k 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
1answer
110 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
589 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();?>"> <?...
1
vote
1answer
17k 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
94 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
131 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
2k 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
2k 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
976 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
171 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; } add_filter('...
1
vote
1answer
254 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
25 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
101 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 ...
1
vote
4answers
10k 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
3k 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 ...