• Resolved bazza_87

    (@bazza_87)


    Hi there,

    Great theme! Just having a bit of trouble with the default post image for the Recent Posts widget

    I am trying to work out how to replace the images/default.png image to one in my child theme?

    I have been able to replace the file itself, but it swaps each update obviously and have mimiked the location in my child theme, but it has a static reference to that specific file from the looks.so that the Recent Posts

    I tried using the Featured Image section in the Supernova Options, but that doesn’t seem to override it. If I manually set a featured image for a post it swaps over to it fine, but I just want to swap the default image for all posts.

    What is the best way to achieve this?

    Thanks Bazza.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,
    Sorry there is no hook for changing the default.png image, but probably I’ll add that in the future version , so you can change the default image. But for now a little script can solve your issue I wrote for you.

    Just replace the new-default.png to any image you like.

    (function($){
        $(document).ready(function(){
            var source, newSrc,
                defaultImage = 'default.png',
                newImage     = 'new-default.png';
    
            $('img[alt="Default Image"]').each(function(){
                source = $(this).attr('src');
                if( source.indexOf(defaultImage) >= 0 ){
                    newSrc = source.replace( defaultImage , newImage );
                    $(this).attr('src', newSrc);
                }
            });
        });
    })(jQuery);
    Thread Starter bazza_87

    (@bazza_87)

    Awesome! Thank you for that, it should do the trick nicely.

    Looking at the code, it doesn’t look like it would go in the functions.php file.

    Where about’s would be the correct spot to locate that code? Should it go in the header being a script, or would it do directly in the file for the home page? (would that be loop-page.php?)

    Just want to make sure I am putting it in the correct place that’s all..

    Thanks.

    Just paste it in Apperance > Supernova Options > Advance > Header Scripts

    Thread Starter bazza_87

    (@bazza_87)

    Nice, it worked perfectly.

    Once I realised I had to use a relative url instead of an absolute one… ??

    The absolute url took it to https://site.com/wp-content/themes/supernova/images/https://site.com//wp-content/themes/supernova-child/images/default.png which obviously won’t work…

    Replacing 'new-default.png' with '../../supernova-child/images/default.png' worked but so all is good!

    Thank you for your quick help sorting that issue out! ??

    Thread Starter bazza_87

    (@bazza_87)

    (Sorry forgot to mark as resolved)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Post Default Featured Image In Child Theme’ is closed to new replies.