---
description: Singleton entity, contains essential blog informations
---

# Blog

### Properties & methods

<table data-full-width="false"><thead><tr><th width="239">Property</th><th width="425.3333333333333">Description</th><th>Type</th></tr></thead><tbody><tr><td>ID</td><td>Site ID</td><td>int</td></tr><tr><td>archive_link(<em>post_type</em>)</td><td>Post type archive link</td><td>string</td></tr><tr><td>archive_title(<em>post_type</em>)</td><td>Post type archive title</td><td>string</td></tr><tr><td>body_class</td><td>The class names for the body element</td><td>string</td></tr><tr><td>breadcrumb</td><td>Default navigational aid</td><td>array</td></tr><tr><td>charset</td><td>Displays the “Encoding for pages and feeds”</td><td>string</td></tr><tr><td>debug</td><td>Symfony debug mode</td><td>bool</td></tr><tr><td>description</td><td>Displays the “Tagline”</td><td>string</td></tr><tr><td>domain</td><td>Blog current domain</td><td>string</td></tr><tr><td>environment</td><td>Symfony environment</td><td>string</td></tr><tr><td>home_link(<em>path</em>)</td><td>URL for the current site</td><td>string</td></tr><tr><td>info(<em>name</em>)</td><td>Information about the current site</td><td>string</td></tr><tr><td>language</td><td>Language code for the current site <em>( ex : en-US )</em></td><td>string</td></tr><tr><td>language_attributes</td><td>HTML lang attribute ( ex : lang="en-US" )</td><td>string</td></tr><tr><td>languages</td><td>Return all available languages</td><td>array</td></tr><tr><td>locale</td><td>Locale code for the current site <em>( ex : en )</em></td><td>string</td></tr><tr><td>login_link(<em>redirect</em>)</td><td>Retrieves the login URL</td><td>string</td></tr><tr><td>maintenance_mode</td><td>Maintenance mode</td><td>bool</td></tr><tr><td>menu</td><td>Return <a href="../../guides/wp-steroids-plugin/menu">navigation entity</a></td><td>object</td></tr><tr><td>meta</td><td>Get site meta</td><td>mixed</td></tr><tr><td>network_home_link(<em>path</em>)</td><td>Retrieves the home URL for the current network.</td><td>string</td></tr><tr><td>option(<em>name</em>)</td><td>Retrieves an option value based on an option name</td><td>string</td></tr><tr><td>options</td><td>Return option helper</td><td>object</td></tr><tr><td>paged</td><td>Current pagination offset for archive</td><td>int</td></tr><tr><td>pagination</td><td>Default archive pagination</td><td>array</td></tr><tr><td>posts(<em>args, order, limit</em>)</td><td>Perform a WP_Query, return PostCollection</td><td>object</td></tr><tr><td>posts_per_page</td><td>Default posts per page value</td><td>int</td></tr><tr><td>privacy_policy_link</td><td>The URL to the privacy policy page</td><td>string</td></tr><tr><td>privacy_policy_title</td><td>The title of the privacy policy page</td><td>string</td></tr><tr><td>queried_object</td><td>Return WP_Query queried object</td><td>mixed</td></tr><tr><td>search_link(<em>query</em>)</td><td>Retrieves the permalink for a search</td><td>string</td></tr><tr><td>terms(<em>args, order, limit</em>)</td><td>Perform a WP_Term_Query, return TermCollection</td><td>object</td></tr><tr><td>title</td><td>Page title for all areas of blog</td><td>string</td></tr><tr><td>user</td><td>Current connected <a href="user">user entity</a></td><td>object</td></tr><tr><td>users(<em>args, order, limit</em>)</td><td>Perform a WP_User_Query, return UserCollection</td><td>object</td></tr><tr><td>version</td><td>Version set in project composer.json</td><td>string</td></tr><tr><td>is_admin</td><td>Current user is an administrator</td><td>bool</td></tr><tr><td>is_archive</td><td>The query is for an existing archive page</td><td>array</td></tr><tr><td>is_customize_preview</td><td>The site is being previewed in the Customizer</td><td>bool</td></tr><tr><td>is_front_page</td><td>The query is for the front page of the site.</td><td>bool</td></tr><tr><td>is_single</td><td>The query is for an existing single post</td><td>bool</td></tr><tr><td>is_tax</td><td>The query is for an existing custom taxonomy archive page</td><td>bool</td></tr></tbody></table>

### Examples

#### Usage of blog properties in layout.html.twig

```twig
<!DOCTYPE html>
<html lang="{{ blog.locale }}">
<head>
    <meta charset="{{ blog.charset }}">
    <meta http-equiv="Content-Type" content="text/html; charset={{ blog.charset }}" />
    <title>{{ blog.title|raw }}</title>
    {{ wp_head() }}
    {% if blog.custom_fields.matomo.domain|default %}
    <script>
        var _paq = window._paq = window._paq || [];
        _paq.push(['trackPageView']);
        _paq.push(['enableLinkTracking']);
        (function() {
            var u="https://{{ blog.custom_fields.matomo.domain }}/";
            _paq.push(['setTrackerUrl', u+'matomo.php']);
            _paq.push(['setSiteId', '1']);
            var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
            g.async=true; g.src='//cdn.matomo.cloud/{{ blog.custom_fields.matomo.domain }}/matomo.js'; s.parentNode.insertBefore(g,s);
        })();
    </script>
    {% endif %}
</head>
<body class="{{ blog.body_class }}">
...
```

#### **Display breadcrumb**

```twig
<ul>
  {% for page in blog.breadcrumb %}
    <li>
      {% if not loop.last %}
        <a href="{{ page.link }}">{{ page.title }}</a>
      {% else %}
        {{ page.title }}
      {% endif %}
    </li>
  {% endfor %}
</ul>
```

#### **Display custom field**

Get specific ACF Option page value\
&#xNAN;_&#x73;ee_ [_https://www.advancedcustomfields.com/resources/options-page/_](https://www.advancedcustomfields.com/resources/options-page/)

<div align="left"><figure><img src="https://2528877867-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZhdVRcuWfQoG77xbyM8p%2Fuploads%2FEBjrWWHOCb4OnrZoReYH%2FScreenshot%20from%202023-06-25%2016-25-16.png?alt=media&#x26;token=f7a1c7ff-89a8-42fb-9500-baa239305a43" alt=""><figcaption><p>WordpressBundle adds a new return format</p></figcaption></figure></div>

```twig
{{ blog.custom_fields.my_option }}
```

#### **Display meta**

Metadata for a site\
&#xNAN;_&#x73;ee_ [_https://developer.wordpress.org/reference/functions/get\_site\_meta/_](https://developer.wordpress.org/reference/functions/get_site_meta/)

```twig
{{ blog.meta.my_meta }}
```

#### **Display blog info**

Information about the current site\
&#xNAN;_&#x73;ee_ [_https://developer.wordpress.org/reference/functions/get\_bloginfo/_](https://developer.wordpress.org/reference/functions/get_bloginfo/)

```
{{ blog.info.name }}
```

#### Display language selector

Return languages, using [WPML](https://wpml.org/) or [MSLS](https://msls.co/)

```liquid
{% if blog.languages %}
  <ul>
    {% for language in blog.languages %}
        <li>
          <a class="{{ language.active ? 'active' : 'inactive' }}" href="{{ language.url }}">{{ language.language_code }}</a>
        </li>
    {% endfor %}
  </ul>
{% endif %}
```

#### **Display menu**

Return [navigation entity](../../guides/wp-steroids-plugin/menu)

<pre class="language-liquid"><code class="lang-liquid"><strong>{% if blog.menu.footer %}
</strong>&#x3C;ul>
    {% for item in blog.menu.footer.items %}
      &#x3C;li>
        &#x3C;a href="{{ item.link }}" class="{{ item.class|default }}" target="{{ item.target|default('_self') }}" rel="{% if item.target|default == '_blank' %}noreferrer noopener{% endif %}">{{ item.title|raw }}&#x3C;/a>
      &#x3C;/li>
    {% endfor %}
&#x3C;/ul>
{% endif %}

</code></pre>

#### Display option

Retrieves an option value based on an option name.\
&#xNAN;_&#x73;ee_ [_https://developer.wordpress.org/reference/functions/get\_option/_](https://developer.wordpress.org/reference/functions/get_option/)

```
{{ blog.option.my_option }}
```

#### Query posts : $criteria=\[], array $orderBy = null, $limit = null, $offset = null

Perform a WP\_Query, return PostCollection\
&#xNAN;_&#x73;ee_ [_https://developer.wordpress.org/reference/classes/wp\_query/_](https://developer.wordpress.org/reference/classes/wp_query/)\
\
Please note that post query should be done in a controller

<pre class="language-twig"><code class="lang-twig"><strong>{% set posts = blog.posts({post_type:'guide', tax_query: [{taxonomy:'type', field:'slug', terms:'test'}]}, null, 6 ) %}
</strong>{% for post in posts %}
     &#x3C;a href="{{ post.link }}">{{ post.title }}&#x3C;/a>
{% endfor %}
</code></pre>

#### Query terms : $criteria=\[], array $orderBy = null, $limit = null, $offset = null

Perform a WP\_Term\_Query, return TermCollection\
see [https://developer.wordpress.org/reference/classes/WP\_Term\_Query/\_\_construct/](https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/)\
\
Please note that term query should be done in a controller

```twig
{% for type in blog.terms('type') %}
    <label>
        <input type="radio" value="{{ type.slug }}" name="type"><span>{{ type.title }}</span>
    </label>
{% endfor %}
```

#### Query users : $criteria=\[], array $orderBy = null, $limit = null, $offset = null

Perform a WP\_User\_Query, return UserCollection\
&#xNAN;_&#x73;ee_ [_https://developer.wordpress.org/reference/classes/wp\_user\_query/_](https://developer.wordpress.org/reference/classes/wp_user_query/)\
\
Please note that user query should be done in a controller

```twig
{% set users = blog.users({role:'subscriber'}, null, 6 ) %}
{% for user in users %}
     <a href="{{ user.link }}">{{ user.display_name }}</a>
{% endfor %}
```
