This is wrong:
<li class="<?php post_class;?>"> <?php the_title(); ?> </li>
That is, this-- post_class
-- is wrong. post_class()
is a function. What you have written is going to get you a, most likely, "undefined constant" Notice
and won't work.
Secondly, that is not really the way post_class()
is used. Add post_class()
to your outer post wrapper, without the class=
part which is generated by post_class()
, not to individual elements in the post. What you are doing is going to add the same classes to both the li
and the p
which is going to cause trouble properly targeting individual pieces of the layout and will also generate a lot of unnecessary markup. For example:
13 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
14 <?php twentyfourteen_post_thumbnail(); ?>
15
16 <header class="entry-header">
17 <?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) &&
twentyfourteen_categorized_blog() ) : ?>
18
https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-content/themes/twentyfourteen/content.php#L13
Now you would use something like:
.category-abc .entry-header {
background:red;
}
To target <header class="entry-header">
.
Yes, category-{category_name}
should work:
Category
Category template files and pageviews displaying posts feature the class selectors: post post-id category-ID category-name
http://codex.wordpress.org/Function_Reference/post_class
But the "name" will be the slug not the human readable name-- that is "abc-def" and not "Abc Def".