Plugin Author
Ajay
(@ajay)
Hi, you can filter “crp_before_list_item” to add the conditional. (Line 96)
You’ll need a function similar to this:
function hook_crp_before_list_item( $before_list_item, $result ) {
}
add_filter( "crp_before_list_item", "hook_crp_before_list_item", 2);
$before_list_item is what you set in the Settings page i.e. <li>
and the $result is the post object for the current post.
Thread Starter
sem101
(@sem101)
Thanks Ajay, I almost have it work. I tried this code quickly!
Problems:
1. $output displays above content
2. how get $title ?
3. It says “No related posts found” (see #1)
Can you look at my code please?
function my_function() {
echo ':-)';
}
function hook_crp_before_list_item( $before_list_item, $result, $output = null ) {
$before_list_item = my_function();
$output .= $before_list_item;
$output .= '<li><a href="' . get_permalink( $result->ID ) . '">' . $result->ID . '</a></li>';
echo $output;
}
add_filter( 'crp_before_list_item', 'hook_crp_before_list_item', 2, 2 );
Thread Starter
sem101
(@sem101)
I think I gots it:
function my_function() {
return ':-)';
}
function hook_crp_before_list_item( $before_list_item, $result, $output = null ) {
$output .= my_function();
$output .= $before_list_item;
//$output .= '<li><a href="' . get_permalink( $result->ID ) . '">' . get_the_title( $result->ID ) . '</a></li>';
return $output;
}
add_filter( 'crp_before_list_item', 'hook_crp_before_list_item', 2, 2 );
Plugin Author
Ajay
(@ajay)
function my_function() {
return ':-)';
}
function hook_crp_before_list_item( $before_list_item, $result ) {
$output = my_function();
$output .= $before_list_item;
return $output;
}
add_filter( 'crp_before_list_item', 'hook_crp_before_list_item', 2, 2 );
This should work.