Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1235563

    One really annoying thing about POST FORMAT = LINK is that the URL I specify in the content area isn’t ever used within search results or rss feeds. It just gives you a link to the post with a title and image. The user than has to click the title to visit the actual link. I would prefer that the search result just directly link to the correct link URL. I figured out how to get the correct URL (for the permalink) within the standard WordPress search results, but how do I do it for the ajax search results?

    I am using a child theme and prefer not to modify any parent theme files.

    I did some searching and I found this function that I can put in my child theme’s functions.php file:

    
    add_filter('avf_ajax_search_query', 'avf_modify_ajax_search_query', 10, 1);
    function avf_modify_ajax_search_query($search_parameters)
    {
        ...
    }
    

    I found a few posts showing how to re-order the search results, but none that show how to change the permalinks based on the post format. I have no idea how to use this function to modify the permalink to the correct URL for post format = link (specified within the content area).

    Any idears?

    #1235680

    Hey G,

    Unfortunately, it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However, if it’s really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Victoria

    #1235805

    Hey Victoria,

    I am a web developer. I would just need the information on the parameters I can use (and how they work) for the avf_ajax_search_query() function. Does this information exist somewhere? If this function is not capable of altering the permalink for a search result, would it work to copy (and alter) the avia_ajax_search function from the functions-enfold.php file in the parent theme and place in my child theme’s functions.php file?

    #1235822

    Nevermind, I figured it out on my own. Probably could use some validation and cleaning up of the URL (in case there is extra formatting in the post content area), but here’s a solution for anyone else interested.

    Open up functions-enfold.php in parent theme and copy the entire function that starts with:

    if( ! function_exists( ‘avia_ajax_search’ ) )

    Paste this function into your child theme’s functions.php file and then make this tiny modification:

    replace this:

    $link = apply_filters( 'av_custom_url', get_permalink( $post->ID ), $post );

    with this:

    $link = apply_filters( 'av_custom_url', get_permalink( $post->ID ), $post );
    /*  modify link to use the the actual URL specified within the content area for "LINK" post format  */
    if ( get_post_format( $post->ID ) == "link" ) {
        $link = strip_shortcodes($post->post_content);
    }

    if anyone else has a more elegant solution, I’d love to hear it. I would prefer to not have to copy the entire avia_ajax_search function, but this works for now.

    #1236066

    Hi G,

    Glad you got it working for you and thank you for sharing your solution! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

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