Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1025173

    Hi,

    in case I forgot to upload a featured image to
    – posts
    – pages

    I would like to show a default image, that also appears in the search results!

    I found here from @ismael an old snippet:
    https://kriesi.at/support/topic/change-default-thumbnail-image/#post-668404

    add_filter('avf_loop_index_blog_meta', 'avf_loop_index_blog_meta_mod', 10, 1);
    function avf_loop_index_blog_meta_mod($output) {
    	$link = get_permalink();
    	$fallback = strpos($output, 'iconfont');
    
    	if ($fallback <= 200) {
    	    $output = "<a href='{$link}' class='small-preview' title='Advanced Post'><img src='FALLBACK IMAGE URL HERE'/></a>";
    	}
    
    	return $output;
    }

    P.S.: yes, I have replaced in the snippet the right image path :-)

    but when I look at my search results, then all the posts & pages, where I forgot to upload a featured image, still have not the default featured image; maybe this snippet is is not the right one for showing a default featured image of posts & pages (!) in the search results because “iconfont” appears in the snippet?

    Somewhere in the internet I found this snippet, but it still does not work with ENFOLD:

    if ( has_post_thumbnail() ) {
    the_post_thumbnail();
    } else { ?>
    <background-image=url("https://mysite.de/wp-content/uploads/sites/2/2018/10/defaultfeaturedimage.jpg")>
    <?php } 

    Could you please give me a newer, right snippet for it (no plugin)? Thanks a lot.

    #1025680

    Hey Gitte,

    How and where ahve you added that snippet? :)

    Best regards,
    Basilis

    #1025685

    this snippet comes to the functions.php

    #1027295

    Hi,

    That snippet is not doing anything at all. If you want to use that you need to edit a template, where it does load it properly.
    Else you have to hook in that specific section.
    For further help with that as it is outside of our Support Scope, you can hire someone to help you.

    Best regards,
    Basilis

    #1027309

    What ENFOLD file do I need to use for this according to @ismael‘s suggestion?

    #1028343

    Hi,

    That is for the blog or single post pages. Did you modify the loop-search.php file to display the thumbnails? Please post the content of the modified file on pastebin.com.

    Best regards,
    Ismael

    #1028646

    I still haven’t made any changes to any file in ENFOLD.
    I only tried this snippet in the my Code-Snippets-Plugin (which holds every snippet that normally goes to the function.php):

    add_filter('avf_loop_index_blog_meta', 'avf_loop_index_blog_meta_mod', 10, 1);
    function avf_loop_index_blog_meta_mod($output) {
    	$link = get_permalink();
    	$fallback = strpos($output, 'iconfont');
    
    	if ($fallback <= 200) {
    	    $output = "<a href='{$link}' class='small-preview' title='Advanced Post'><img src='FALLBACK IMAGE URL HERE'/></a>";
    	}
    
    	return $output;
    }

    But probably that is not the right snippet or it is not complete, so that also at the search results page this default fallback image appears.

    #1029783

    Hi,

    Again, that snippet is for the single post pages. It’s not going to work on the search results page. Did you add any modifications the search page templates? The posts thumbnails should not be displayed on the search results page by default.

    Best regards,
    Ismael

    #1029822

    okay, thank you, I guess I understand now … but what can I do so that this default/fallback featured image is also shown in the search results. I haven’t added anything to search files of ENFOLD (and I don’t know what and how)

    #1030349

    Hi,

    This thread should help you display thumbnails on the search results page:

    // https://kriesi.at/support/topic/show-featured-images-in-search-results-page/

    If you want to add a placeholder, look for this line:

    $searchthumb = get_the_post_thumbnail( $the_id, 'large' );
    

    Replace it with:

    
    $placeholder = "<img src='PLACE HOLDER IMAGE HERE' />";
    $searchthumb = get_the_post_thumbnail( $the_id, 'large' );
    $searchthumb = $searchthumb ? $searchthumb : $placeholder;
    

    Best regards,
    Ismael

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

You must be logged in to reply to this topic.