Search result name details

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search result name details

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13707
    synergy
    synergy
    Participant

    Hi Ernest,

    Just a quick question. I am using Ajax Pro to search a bunch of pages that all have the title starting with ‘supplier’ followed by the suppliers name (supplier-name). I’ve done this for ease of use so that all the supplier pages are in the same wordpress editing area and easily identified as such. However I would prefer the search result to show just the supplier name rather than the name and prefix (supplier-).

    Is the best way to achieve this to setup a custom field with the preferred suppliers name as a value and then set that custom field as the option in the ‘Primary Title Field for Posts/Pages/CPT’ setting in ‘Advanced Options – Content’?

    Again, many thanks.

    #13716
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    I believe there is a better, faster way, with a custom code, by simply replacing the ‘supplier-‘ string before it. So, I would recommend trying this one out:

    Try placing this into the functions.php file in your active theme/child theme directory, copy from line 3. Please be careful when editing files, always use FTP, and have a back-up of everything.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #16339
    synergy
    synergy
    Participant

    Hi Ernest,

    My website WordPress has updated to 4.9.2 and I placed this script in the updated functions.php from line 2 onwards (see below) and it is now not working.

    1.<?php
    2./**
    3.*Filter to remove ‘Supplier’ from Ajax Pro Search results display images
    4.*/
    5.add_filter(‘asp_results’, ‘asp_replace_supplier_name’, 10, 4);
    6.function asp_replace_supplier_name($results, $sid, $is_ajax, $args) {
    7.foreach ($results as $k=>&$r) {
    8.$r->title = str_replace(‘supplier-‘, ”, $r->title);
    9.}
    10. return $results;
    11.}
    12./**
    13. * Main WordPress API
    14. *
    15. * @package WordPress
    16. */

    Thanks in advance.

    #16350
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    The filter endpoints have not changed recently, this should work just like before.

    Make sure that the correct file was this copied into. Sometimes I mistake the theme directory to another theme.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Search result name details’ is closed to new replies.