Wordpress Bundle
  • What is Wordpress Bundle?
  • Getting started
    • Installation
    • Wordpress
    • Router
    • Cron job
    • Templates
  • Reference
    • Argument resolver
    • Controller
      • AdminAction
      • BlogController
      • FrontAction
      • WordpressAction
    • Entity
      • Block
      • Blog
      • Comment
      • File
      • Image
      • Menu
      • MenuItem
      • Post
      • Term
      • User
    • Repository
      • CommentRepository
      • PostRepository
      • TermRepository
      • UserRepository
    • Service
      • PaginationService
      • BreacrumbService
  • Guides
    • Server requirements
    • Install plugins
    • Use Multisite
    • Gutenberg
    • WP Steroids plugin
      • Image options
      • Maintenance
      • Admin pages removal
      • WYSIWYG Editor
      • Feature Support
      • Multi-site configuration
      • Constants definition
      • ACF configuration
      • Menu
      • Custom Post type
      • Advanced permalink settings
      • Custom Taxonomy
      • Templates
      • Page states
      • External table viewer
      • Roles
      • Optimisations
      • Security
      • Search
    • Twig Cookbook
    • Inject variables in all templates
    • Internationalization
    • Extending Wordpress Bundle
    • Error pages
    • Site health
  • Integrations
    • Advanced Custom Fields
      • Install ACF PRO
  • Extras
    • Migrating from 1.x to 2.0
    • Roadmap
    • Changelog
    • Alternatives
Powered by GitBook
On this page
  • Properties & methods
  • Examples

Was this helpful?

  1. Reference
  2. Entity

Blog

Singleton entity, contains essential blog informations

Properties & methods

Property
Description
Type

ID

Site ID

int

archive_link(post_type)

Post type archive link

string

archive_title(post_type)

Post type archive title

string

body_class

The class names for the body element

string

breadcrumb

Default navigational aid

array

charset

Displays the “Encoding for pages and feeds”

string

debug

Symfony debug mode

bool

description

Displays the “Tagline”

string

domain

Blog current domain

string

environment

Symfony environment

string

home_link(path)

URL for the current site

string

info(name)

Information about the current site

string

language

Language code for the current site ( ex : en-US )

string

language_attributes

HTML lang attribute ( ex : lang="en-US" )

string

languages

Return all available languages

array

locale

Locale code for the current site ( ex : en )

string

login_link(redirect)

Retrieves the login URL

string

maintenance_mode

Maintenance mode

bool

menu

object

meta

Get site meta

mixed

network_home_link(path)

Retrieves the home URL for the current network.

string

option(name)

Retrieves an option value based on an option name

string

options

Return option helper

object

paged

Current pagination offset for archive

int

pagination

Default archive pagination

array

posts(args, order, limit)

Perform a WP_Query, return PostCollection

object

posts_per_page

Default posts per page value

int

privacy_policy_link

The URL to the privacy policy page

string

privacy_policy_title

The title of the privacy policy page

string

queried_object

Return WP_Query queried object

mixed

search_link(query)

Retrieves the permalink for a search

string

terms(args, order, limit)

Perform a WP_Term_Query, return TermCollection

object

title

Page title for all areas of blog

string

user

object

users(args, order, limit)

Perform a WP_User_Query, return UserCollection

object

version

Version set in project composer.json

string

is_admin

Current user is an administrator

bool

is_archive

The query is for an existing archive page

array

is_customize_preview

The site is being previewed in the Customizer

bool

is_front_page

The query is for the front page of the site.

bool

is_single

The query is for an existing single post

bool

is_tax

The query is for an existing custom taxonomy archive page

bool

Examples

Usage of blog properties in layout.html.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

<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

{{ blog.custom_fields.my_option }}

Display meta

{{ blog.meta.my_meta }}

Display blog info

{{ blog.info.name }}

Display language selector

{% 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

{% if blog.menu.footer %}
<ul>
    {% for item in blog.menu.footer.items %}
      <li>
        <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 }}</a>
      </li>
    {% endfor %}
</ul>
{% endif %}

Display option

{{ blog.option.my_option }}

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

{% set posts = blog.posts({post_type:'guide', tax_query: [{taxonomy:'type', field:'slug', terms:'test'}]}, null, 6 ) %}
{% for post in posts %}
     <a href="{{ post.link }}">{{ post.title }}</a>
{% endfor %}

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

{% 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

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

Last updated 1 year ago

Was this helpful?

Return

Current connected

Get specific ACF Option page value see

Metadata for a site see

Information about the current site see

Return languages, using or

Return

Retrieves an option value based on an option name. see

Perform a WP_Query, return PostCollection see Please note that post query should be done in a controller

Perform a WP_Term_Query, return TermCollection see Please note that term query should be done in a controller

Perform a WP_User_Query, return UserCollection see Please note that user query should be done in a controller

https://www.advancedcustomfields.com/resources/options-page/
https://developer.wordpress.org/reference/functions/get_site_meta/
https://developer.wordpress.org/reference/functions/get_bloginfo/
WPML
MSLS
navigation entity
https://developer.wordpress.org/reference/functions/get_option/
https://developer.wordpress.org/reference/classes/wp_query/
https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/
https://developer.wordpress.org/reference/classes/wp_user_query/
navigation entity
user entity
WordpressBundle adds a new return format