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

Was this helpful?

  1. Guides

Twig Cookbook

Filters

Generate handle from string ( use Wordpress sanitize_title function )

{{ 'My title'|handle }}

--> output : my-title

Handle Wordpress "Read more" tag

{{ post.content|more|raw }}

Resize image

<img src ="{{ post.thumbnail|resize(800,600) }}"/>

Generate picture

{{ post.thumbnail|picture(1280, 680, {'max-width: 420px':[420,665], 'max-width: 768px':[768,820]})|raw }}

--> ouput 

<picture>
    <source media="(max-width: 420px)" srcset="/uploads/image-420x665.webp" type="image/webp"/>
    <source media="(max-width: 420px)" srcset="/uploads/image-420x665.jpg" type="image/jpeg"/>
    <source media="(max-width: 768px)" srcset="/uploads/image-768x820.webp" type="image/webp"/>
    <source media="(max-width: 768px)" srcset="/uploads/image-768x820.jpg" type="image/jpeg"/>
    <source srcset="/uploads/image-1280x680.webp" type="image/webp"/>
    <img src="/uploads/image-1280x680.jpg" alt="" loading="lazy" width="1280" height="680"/>
</picture>

Functions

Execute php functions

{{ fn('sanitize_title', 'My title') }} 
{{ function('sanitize_title', 'My title') }}
{{ shortcode(post.content) }}
{{ login_url() }}
{{ search_form() }}
{{ archive_url('guide') }}
{{ attachment_url(10) }}
{# post_url(value, type) #}
{{ post_url('My post', 'title') }}
{{ term_url(10, 'item') }}
{{ dynamic_sidebar(1) }}
{{ comment_form() }}
{{ is_active_sidebar(1) }}
{{ _e('Submit') }}
{{ __('Submit') }}
{{ _x() }}
{{ _n() }}

Fire the wp_head action

{{ wp_head() }}

Fire the wp_footer action.

{{ wp_footer() }}

Instantiate Wordpress bundle post entity

{% set post = Post(10) %}

Instantiate bundle user entity

{% set user = User(10) %}

Instantiate bundle term entity

{% set term = Term(10) %}

Instantiate bundle image entity

{% set image = Image(10) %}

Generate transparent image placeholder

<img src="{{ pixel(10,20) }}"/>

PreviousSearchNextInject variables in all templates

Last updated 2 years ago

Was this helpful?

Search content for shortcodes and filter through their hooks

Get

Display

Retrieves the permalink for a

Retrieve the URL for an

Get post permalink by value, available options are : id, ,

Get

Display

Outputs a complete for use within a template

Determines whether a

Retrieve the of text

Retrieve with gettext context

Translates and retrieves the form based on the supplied number

shortcodes
login url
search form
post type archive
attachment
state
title
term permalink
dynamic sidebar
commenting form
sidebar contains widgets
translation
translated string
singular or plural