• Hey,

    I am using your code in my function.php to add categories to my output

    function crp_list_cats( $output, $result, $args ) {
    	$categories = get_the_category_list( ', ', '', $result->ID );
    
    	$output .= ' ' . $categories;
    
    	return $output;
    }
    add_filter( 'crp_after_list_item', 'crp_list_cats', 10, 3 );

    I am not proficient in php,…is there a way to display the category before the title. Right now it is outputting an image, then the title, then the category

    THANKS!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ajay

    (@ajay)

    You could potentially try using crp_title – https://github.com/WebberZone/contextual-related-posts/blob/v3.1.0/includes/output-generator.php#L204

    function crp_list_cats( $output, $result, $args ) {
    	$categories = get_the_category_list( ', ', '', $result->ID );
    
    	$output = $categories . ' ' . $output;
    
    	return $output;
    }
    add_filter( 'crp_title', 'crp_list_cats', 10, 3 );
    
    Thread Starter juniojeff

    (@juniojeff)

    Thanks for your reply Ajay. There is a weird behavior when I use that – it creates a link to the category but then makes the title of the post into plain text.

    ANYWAYS…something, maybe a little simpler and actually even more important. When I use [crp limit=”1″ show_author=”1″], it shows the title and “by XXX”. Is there a way to remove the link to the author?

    Thanks so much Ajay

    Plugin Author Ajay

    (@ajay)

    You’re right – I forgot the crp_title is itself wrapped into a link. I think you’ll need to do a custom install in order to change the order.

    On show_author, are you thinking putting an author name but not a link? I think this would again fall into the custom install if you’re looking to change the outputs.

    You can use the same way as you do WP_Query: https://webberzone.com/support/knowledgebase/crp-query/

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add Category to Output’ is closed to new replies.