How to use custom excerpt
-
Depending on my post type, I’m using different custom fields for the excerpt. In the code below
$thecontent
is what’s showing for the excerpt in my search results template. I’m using this in tandem with search filter pro.So the below code is for a search filter pro search. But I would like to use relevansi’s custom generated excerpt when there is a search string present… in the context of search filter pro, that’s the
_sf_s
query string.How can I use Relevanssi’s custom excerpt in this case? I’ve looked at this page: https://www.relevanssi.com/user-manual/filter-hooks/relevanssi_excerpt_part/ … but it’s not clear how to use it in this context.
$thecontent = get_post_meta($postid,'intro_text', true); if(empty($thecontent)) { $thecontent = get_the_excerpt($postid); $cust_excerpt = trim(get_post_meta($postid,'cust_excerpt', true)); if(!empty($cust_excerpt)) { $thecontent = $cust_excerpt; } } if($posttype == 'people' && empty($thecontent)) { $thecontent = get_post_meta($postid,'automated_bio', true); $thecontent = strip_tags($thecontent); $thecontent = trim($thecontent); } if($posttype == 'calendar_event') { $location = get_post_meta($postid,'event_location', true); $address = explode( ',' , $location['address']); $theaddress = ''; if(!empty($address)) { $theaddress .= $address[0].'<br/>'; //place name $theaddress .= $address[1].'<br/>'; // street address $theaddress .= $address[2].','.$address[3]; // city, state zip_close() $theaddresslink = 'https://www.google.com/maps?saddr=My+Location&daddr=' . $location['lat'] . ',' . $location['lng']; } else { $theaddress .= get_post_meta($postid,'event_address', true); $theaddresslink = strip_tags($theaddress); } $thecontent = '<a href="' . $theaddresslink . '" class="lib-card--address icon-map-marker">' . $theaddress . '</a>'; } elseif( !empty($thecontent) ) { $thecontent = apply_filters( 'the_content', $thecontent ); $thecontent = preg_replace("/<img[^>]+\>/i", "", $thecontent); ... ...
The page I need help with: [log in to see the link]
- The topic ‘How to use custom excerpt’ is closed to new replies.