Any way to display Wordpress site logo?

I’m hoping to use the Wordpress site logo in an L&L template, but after scouring the documentation I’m coming up short. Is there any way to do this?

Welp, against all odds I’ve answered my own question. Getting there was a little convoluted, but this works for me:

<Set local=site_logo_id><Setting site_logo /></Set>
<Loop type=attachment times=1 id="{Get local=site_logo_id}">
  <img src="{Field url}" srcset="{Field srcset}" alt="{Field alt}">

I found my way to the answer via the Settings page in L&L docs. Unfortunately, the Wordpress Codex page linked there does not mention site_logo. I was able to find it by digging around in the hidden options page of my Wordpress install (/wp-admin/options.php).

This seems like a common enough need that it should be more clearly documented somewhere.


That’s awesome! Could it be this is a new block theme/FSE option?

You should be able to make your template a bit more concise like so:

<Loop type=attachment times=1 id="{Setting site_logo}">
  <img src="{Field url}" srcset="{Field srcset}" alt="{Field alt}">

I would save the image output to a variable if I were going to reuse this multiple times on the page to avoid querying attachments too many times. It could even be saved in a “global variables” layout loaded in the site head for easy use as a variable in various templates.

1 Like

@julia I’m not sure if site_logo is a new setting to FSE. It could be, but I know that Wordpress has included the option to define a site logo for quite awhile. My guess is that the Codex page is just out of date, as it appears they are looking for volunteers to update it.

I just tried your more concise version and it does work—thanks! I’m happy to remove some complexity. I was not sure if something like {Setting site_logo} would work, so I’m glad to know it does.

Fortunately I only need this to happen once, but if I wanted to set a local variable, would I just include the <img> tag within the loop? Would a local variable then be usable outside the loop (but within the template)?