Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #356926

    Hello,

    I wish to change the results of the search function to say “Brands” instead of “Portfolio Items” is there a way to do this?

    Here is an image of what I’m talking about:
    http://i62.tinypic.com/n1c651.jpg

    #357223

    Hi atrifico!

    Try line 9 in /enfold/includes/admin/register-portfolio.php.

    'name' => _x('Portfolio Items', 'post type general name','avia_framework'),
    

    Regards,
    Elliott

    #1224985

    Hi,

    Is there a way to do this without changing the code?
    Maybe adding to the functions.php?
    I’d like to change “Portfolio Items” to “Products” & “Posts” to “Projects & News” please.

    Thanks
    Alice

    #1225820

    Hi Alice,

    Product is a post type added by the WooCommerce or some other e-commerce plugins. Do you need to change the types or just the titles?

    Could you please attach a mockup of what you’re trying to achieve?

    Best regards,
    Victoria

    #1226297

    Hi Victoria,

    In private content is a link to sreenshots to explain the following:

    1. Order of search results: Are there any settings to change the order of the search results so the closest match is the first and the least close match is last? In the example the search word “Stratopanel” shows the product (with the exact name) last in the results. I want it to show at top of the list please.

    2. No result for some pages/2 : If I’m searching for a page title some don’t show in the results. ALL pages, posts, and portfolio items should show and be listed in closest match order from first result to last.

    3. Change wording: I’d like the wording of the search result titles changed to: POSTS = Products & News. PORTFOLIO ITEMS = Products.

    Let me know if you have any trouble with the link.

    Thanks
    Alice

    #1226510

    Hi Alice,

    Please have a look at the following threads:

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1227602

    Hi Victoria,

    Those threads didn’t really help me with what I need. One of the threads explained how to “have products display as the first section in the search results before posts and pages” but I need “portfolio items” to display first, is it just a matter of changing the code to ‘portfolio-items’ instead of ‘products’? (see code below)

    /* Look for Products and place them at the start of the array */
    if (array_key_exists(‘product’, $sorted)) {
    $products_array[‘product’] = $sorted[‘product’];
    unset($sorted[‘product’]);
    $sorted = array_merge($products_array, $sorted);
    }

    The other thread explained how to change the wording in the results when none are found but I just want to change the title names (which i don’t think a plugin can do). I explained what I’d like them to change to in point 3 in my last reply.

    Thanks,
    Alice

    #1228883

    Hi,

    Thank you for the update.

    We can use the avf_ajax_search_label_names filter to change the post type title. Usage examples can be found here:

    // https://kriesi.at/support/topic/search-bar-8/#post-1003538
    // https://kriesi.at/support/topic/change-products-wording-on-ajax-search-menu/#post-866050

    To sort the results by post type, try to use this snippet in the functions.php file.

    function avf_order_search_by_posttype($orderby){
        if (!is_admin() && is_search()) :
            global $wpdb;
            $orderby =
                "
                CASE WHEN {$wpdb->prefix}posts.post_type = 'portfolio' THEN '1' 
                     WHEN {$wpdb->prefix}posts.post_type = 'product' THEN '2' 
                     WHEN {$wpdb->prefix}posts.post_type = 'post' THEN '3'  
                ELSE {$wpdb->prefix}posts.post_type END ASC, 
                {$wpdb->prefix}posts.post_title ASC";
        endif;
        return $orderby;
    }
    add_filter('posts_orderby', 'avf_order_search_by_posttype', 999, 1);
    

    // https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.