Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › the option does not work
- This topic has 11 replies, 2 voices, and was last updated 7 years, 4 months ago by
Ernest Marcinko.
-
AuthorPosts
-
January 7, 2019 at 8:27 am #20653
kliping
Participantthe option does not work, I don´t want to see the url of the image, can you help me please?
January 7, 2019 at 9:30 am #20654Ernest Marcinko
KeymasterHi!
Thank you for the details, it helps me a lot!
I think you are looking at the wrong search instance options. Make sure to edit the search ID 1, where I see the description is still enabled. Turning that off will disable the content.
I hope this helps!
January 7, 2019 at 9:39 am #20655kliping
ParticipantYou cannot access this content.
January 7, 2019 at 9:57 am #20657Ernest Marcinko
KeymasterHi,
It might be part of the WordPress generated excerpt from a shortcode or somathing. Try this configuration: https://i.imgur.com/U6zloZc.png
This will execute the shortcodes and use the content as the main field.January 7, 2019 at 10:53 am #20658kliping
Participantlittle by little it’s better
but now I want it to start with 200 characters and start with the first
January 7, 2019 at 5:35 pm #20663Ernest Marcinko
KeymasterHi,
The ‘Description context’ option is not for removing the first X characters from the results content. That is only possible via a custom code.
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! Change the $remove variable to the number of characters you want to remove.
add_filter('asp_results', 'asp_remove_first_n_characters'); function asp_remove_first_n_characters($results) { $remove = 200; foreach ($results as $k => &$r) { if ( strlen($r->content) > $remove ) $r->content = substr($r->content, $remove); } return $results; }January 8, 2019 at 10:48 am #20669kliping
ParticipantHi, I would need this script to do the function to hide some words, is that possible?
for example… my friend’s house is red
can I hide the word “house”?
it´s possible?
very thanks
January 8, 2019 at 1:40 pm #20681Ernest Marcinko
KeymasterHi,
Try this modified version of the code. Enter the keywords to be replaced to the $words variable, comma separated.
add_filter('asp_results', 'asp_remove_first_n_characters'); function asp_remove_first_n_characters($results) { $remove = 200; // Enter the length to cut $words = 'word1, word2'; // Enter the words to replace // Replace the keywords $words = explode(',', $words); foreach ( $words as $wk => &$word ) { $word = trim($word); if ( $word != '' ) unset($words[$wk]); } if ( count($words) > 0 ) { // implode() words into a pipe-delimited string $pattern = "/\b(" . implode("|", $words) . ")\b/i"; foreach ($results as $k => &$r) { $r->content = preg_replace($pattern, "", $r->content); } } // Trim the length foreach ($results as $k => &$r) { if ( strlen($r->content) > $remove ) $r->content = substr($r->content, $remove); } return $results; }January 9, 2019 at 7:44 am #20686kliping
Participantlast question, I have this example…
In my admin I have this configuration http://prntscr.com/m4r8ls
and my front end I have http://prntscr.com/m4r9mi
I need to look for me in the title of the post http://prntscr.com/m4rdsa
very thanks and I sorry for my English
January 9, 2019 at 12:59 pm #20690Ernest Marcinko
KeymasterHi!
I think that field ‘pyre_title_field’ is not the same as the post title, it does not contain the title, that is why it’s not working. The post title is not a custom field, that cannot be used for filtering.
January 9, 2019 at 3:01 pm #20694kliping
Participantand what solution would there be to be able to filter through the entry field?
January 10, 2019 at 12:12 pm #20698Ernest Marcinko
KeymasterHi,
The title field cannot be used for that, but maybe you could for example create a custom field with the data you need – copy there the title, or part of the title. Then use that for the filter, that should work.
Another possibility is to create a custom taxonomy. -
AuthorPosts
- You must be logged in to reply to this topic.