Get site icon -- replace an image by the site icon in a theme

Hi all,

does anybody knows how I can link an image in html to the Wordpress site icon? Normally it is done using get_site_icon_url() but I cannot find this in Pinegrow.

More info: https://developer.wordpress.org/reference/functions/get_site_icon_url/

thanks for the help,

Hi @24degrees,
I’m not the WordPress actions expert for Pinegrow, but I think this is the best way to do it.

  1. Add an image to your page where you want your site icon to be displayed. Make sure to style it to be square.
  2. Select the image and go to the WordPress actions panel.
  3. Select the ‘IF’ conditional
  4. For the condition you want to check if the site icon is actually set. So, ‘has_site_icon()’.
  5. Next click on the ‘PHP Code’ action.
  6. Add ‘get_site_icon_url();’ into the Function, click the ‘echo’ checkbox, select ‘Attribute’ in the Replace dropdown. and add ‘src’ as the Attribute.

    If you want something else displayed if there is no site icon you would need to add an element to the page next to the image, then add in an Else conditional.
    Hope this helps!
    Bob

Thank you very much @RobM - that works like a charm !

kind regards