Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › I want to use post_id in Advanced Description field › Reply To: I want to use post_id in Advanced Description field
March 11, 2020 at 10:07 am
#26203
Keymaster
Hi!
The post ID is not available via those fields unfortunately, but it should be doable via a simple custom code. First, change the advanced content field to this:
<a href="http://pkmobilereviews.com/compare/?post_id=|post_id|">
{__image}
{titlefield}
</a>
Then, try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter( 'asp_results', 'asp_change_content_post_id', 10, 4 );
function asp_change_content_post_id($results, $search_id, $is_ajax, $args) {
foreach ( $results as $k => &$r ) {
$r->content = str_replace('|post_id|', $r->id, $r->content);
}
return $results;
}