How do I remove categories from this PHP snippet?
I'm editing a WordPress plugin that provides a suggestion for related blog posts.
Here is a screenshot of how it looks now:
I want it to look exactly like the screenshot, but without the "Gratefulness, Happiness" links ... which are just links to categories. Keep the "Recommended for You" and the link to the article, but remove the link to the categories.
If I remove the "foreach ( $siblings as $url => $name )" snippet from the code below, then it gets rid of the categories, but messes up the link to the recommended article.
How should I edit it? To remove the categories but keep everything else?
Note: I'm not sure if this matters for the code below, but the plugin chooses the recommended article based on the previous article in the same category.
ob_start();
do_action( 'iworks_upprev_box_before' );
$value .= ob_get_flush();
if ( $iworks_upprev_options->get_option( 'header_show' ) ) {
$value .= '<h6>';
if ( count( $siblings ) ) {
$value .= sprintf ( '%s ', __('Recommended for You' ) );
$a = array();
foreach ( $siblings as $url => $name ) {
$a[] = sprintf( '<a href="%s" rel="%s">%s</a>', $url, $current_post_title, $name );
}
$value .= implode( ', ', $a);
} else if ( $compare == 'random' ) {
$value .= __('Read more:', 'upprev' );
} else {
$value .= __('Read previous post:', 'upprev' );
}
$value .= '</h6>';
}
Solutions
It looks like all you need to do is comment out this line or remove it:
$value .= implode( ', ', $a);
You can also comment / remove the following lines of code:
$a = array();
foreach ( $siblings as $url => $name ) {
$a[] = sprintf( '<a href="%s" rel="%s">%s</a>', $url, $current_post_title, $name );
}