Is there a filter or something to add these kind of icons based categories and what not to all posts?
I can't seem to find one. I tried the_title but ofc that gets sanitized and just displays the html.. Thanks!
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityWe can style the table with CSS and dashicons.
For our video
category, we can use for example:
.edit-php .wp-list-table tr.category-video td.post-title strong:before {
content: "\f126";
color: #ccc;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 4px;
font-size: 20px;
line-height: 20px;
font-family: "dashicons";
font-weight: normal;
vertical-align: top;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
where we target the tr.category-video
class.
Just check out how it's used in the backend, to get an idea of the CSS attributes.
We can get the list of dashicons here.
Here's it the part of the WP_Posts_List_Table
class that displays the post format icon:
$pad = str_repeat( '— ', $level );
echo "<td $attributes><strong>";
if ( $format = get_post_format( $post->ID ) ) {
$label = get_post_format_string( $format );
echo '<a href="' . esc_url( add_query_arg( array( 'post_format' =>
$format, 'post_type' => $post->post_type ), 'edit.php' ) ) . '"
class="post-state-format post-format-icon post-format-' . $format
. '" title="' . $label . '">' . $label . ":</a> ";
}
<tr>
classes somehow. Thanks mate.
Jun 26, 2015 at 20:18
set_post_format
, but I'm not sure how flexible this is regarding other formats than the default ones. It looks like we are stuck with the default formats defined in get_post_format_strings()
. @jimihenrik