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 of a certain category.
I found this line of code for the actual display of the widget:
public static function list_items( $post, $defaults ) {
setup_postdata( $post );
$post_id = get_the_ID();
$title = get_the_title() ? get_the_title() : $post_id;
$post_class = implode(get_post_class());
$permalink = get_permalink();
$pre_thumbnail = (has_post_thumbnail() && $defaults['thumbnail'] == 'before_title') ? get_the_post_thumbnail(get_the_ID(), $thumbnail_size) : '';
$post_thumbnail = (has_post_thumbnail() && $defaults['thumbnail'] == 'after_title') ? get_the_post_thumbnail(get_the_ID(), $thumbnail_size) : '';
$item = '
<li class="' . $post_class . '">
<a href="' . $permalink . '" title="' . $title . '">
' . $pre_thumbnail . $title . $post_thumbnail . '
</a>
</li>
';
$item = apply_filters('wp_most_popular_list_item_single', $item, $post_id, $title, $post_class, $permalink);
echo $item;
}
While this works, when it displays the classes, they are not spaced properly, so a page that should display: class="post-20 pagetype-page status-publish hentry category-member tag-member"
is instead displaying class="post-20pagetype-pagestatus-publishhentrycategory-membertag-member"
.
Because of this, I cannot target the class category-member
using CSS, or any other classes for that matter. How can I fix this?
I've tried removing the implode()
from the $post_class
array, but that has done nothing. I ave also tried simply using post_class()
and get_post_class()
to no avail.