Namespaces
7 min read
A namespace is the first word of a path: {{ glb.phone }} reads the phone name from the glb namespace. Six are built in and free; one (pseo) is added by Pro. Your own code can add more (see PHP API).
Namespace | Plan | Reads |
|---|---|---|
Free | Global Data variables | |
Free | Values of field groups | |
Free | Current post, term and user | |
Free | Date, time and site facts | |
Free | The current WooCommerce product | |
Free | Values passed by your own code | |
Pro | Data row and page behind a generated page |
An unknown namespace, an unknown name, or a value that is empty renders nothing. Combine with the default filter when you need a fallback: {{ glb.tagline | default('Welcome') }}.
glb: Global Data
{{ glb.key }} is the stored value of the Global Data variable with that key.
Path | Result |
|---|---|
|
|
| nothing |
|
|
- The key is everything after
glb.. Global Data keys must start with a letter and use only lowercase letters, digits and underscores, so every saved key can be written in an expression (older keys with a hyphen or a leading digit cannot; see Troubleshooting). - The value is inserted as stored. If the variable's own value contains
{{ }}, those braces stay as text:{{ glb.a }}whereaisx {{ glb.b }} yprintsx {{ glb.b }} y. (Reading the variable withwpmcf_get_global()or[wpmcf_global]does evaluate its own expressions, one level.) - Password variables are always empty in a template (a
defaultfilter supplies its own fallback, never the password). A site can opt in with thewpmcf/global/the_passwordfilter.
fg: field values
{{ fg.group.field }} reads one field of a field group for the current object. For a group field or a repeater, add the sub keys; for a list, add an index.
{{ fg.products.price }}
{{ fg.products.details.size }} a field inside a Group field
{{ fg.team.members.0.name }} first row of a Repeater
{{ fg.products.tags.0 }} first item of a Checkbox listPart | Meaning |
|---|---|
| The field group key |
| The top-level field key |
further segments | Keys of a group object or indexes of a list ( |
Which object is "current":
- In a field value or a placeholder, the object that value belongs to (the post being edited or viewed; the term, user or comment for those contexts).
- With
wpmcf_resolve_variables(), the object of the context you pass, or the loop post (get_the_ID()) when you pass none. With no object,fgfalls back to the current or queried post; outside any post the result is empty. See PHP API. - On a generated Programmatic SEO page, the page template post.
What comes back:
Field | Printed as |
|---|---|
Text, number, email, URL | The value ( |
True/false |
|
Date | The stored date ( |
Checkbox, multi-select, other lists | Items joined by |
Repeater, group | Rows joined by |
Rules that matter:
- No second evaluation. The value is inserted as stored. A field value that contains
{{ }}is not evaluated when another expression reads it throughfg. (Reading it withwpmcf_get_field()does evaluate it, once.) - Password fields are always empty. So are password sub-fields inside group and repeater values. A site can opt in with the
wpmcf/field/the_passwordfilter. - The value is passed through the
wpmcf/field/valuefilter, like any other read.
wp: posts, terms and the signed-in user
Name | Returns |
|---|---|
| The context object ID, or the loop post ID |
| The title, as |
| The slug ( |
| The post type name |
| The permalink |
| The excerpt, trimmed like core's automatic excerpt |
|
|
| The publish date as stored ( |
| The modified date as stored |
| The author's user ID |
| The ID of the signed-in visitor |
| The visitor's display name |
| The visitor's email |
| The visitor's login |
| The visitor's first name |
| The visitor's last name |
| The term: in a term field value the term itself; elsewhere only when your code puts a |
|
|
|
|
Other names (wp.title, wp.foo) render nothing.
Things to know:
wp.post_*(includingwp.post_id) resolve only in a post context, where the context object is the post. In a term, user, comment or options context they are empty; they never read another post that happens to share the object's ID.wp.user_*are about the viewer, not the post author. They are empty for visitors who are not signed in.- Caching. The first time a
wp.user_*name is printed on a front-end page, the plugin definesDONOTCACHEPAGEand sends no-cache headers, so a page cache does not store one visitor's name and serve it to everyone. This honors WP Rocket, W3 Total Cache, WP Super Cache, LiteSpeed Cache and others that read that constant. Inside wp-admin nothing is changed. Avoidwp.user_*on pages you want cached. wp.term_*read the term of the evaluation context: the context object when the context type isterm(so they work in term field values and inwpmcf_make_context( $term_id, 'term' )), or the term named by the metadata keyterm_idwhen your code sets it with->withMeta( 'term_id', $id ). The metadata wins when both are present. In other contexts they are empty.
sys: date, time and site
Name | Returns | Example |
|---|---|---|
| Four-digit year (site time zone) |
|
| Two-digit month |
|
| Two-digit day |
|
| Today in the site's date format (Settings › General) |
|
| The time in the site's time format |
|
|
|
|
| Unix timestamp |
|
|
|
|
|
|
|
|
|
|
| Site title |
|
| Tagline (empty if none) | |
| Locale |
|
| Charset |
|
| WordPress version |
|
Dates use the site time zone and are translated (date_i18n). Combine with filters: {{ sys.timestamp | date('l') }}. Other names render nothing.
woo: WooCommerce product
Reads the product whose ID is the context object ID. It renders nothing when WooCommerce is not active, when there is no object, or when the object is not a product.
Name | Returns |
|---|---|
| Prices as numbers without currency ( |
| WooCommerce's price markup |
| SKU |
| Quantity, |
| Weight |
| Product name and slug |
| The long and short description |
|
|
| Average rating, number of reviews, units sold |
src: values from your code
src reads the values you pass as the third argument of wpmcf_make_context(). The plugin's own screens never fill it; it exists for your templates.
$context = wpmcf_make_context( null, 'post', [ 'city' => 'London', 'n' => 10 ] );
echo wpmcf_resolve_variables( "{{ src.city == 'London' ? 'Capital' : 'City' }}", $context ); // Capital
echo wpmcf_resolve_variables( "{{ src.n >= 10 && src.city == 'London' ? 'yes' : 'no' }}", $context ); // yes
echo wpmcf_resolve_variables( "{{ src.zip || 'no zip' }}", $context ); // no zipA name that was not passed renders nothing. A dotted path (src.details.size) first looks for a key named details.size, then for details.
pseo: Programmatic SEO pages (Pro)
Available on Pro and above, only where Programmatic SEO evaluates a template (the task's URL, title, SEO texts, page content and structured data) and in field values and Global Data printed on a generated page. Elsewhere it renders nothing.
Path | Returns |
|---|---|
| A column of the page's data row from the data source |
| Slot |
| The generated page's title |
| Its full URL |
| Its path |
| Its language code |
Visit {{ pseo.src.cities.name }}, {{ pseo.src.cities.country | upper }}
{{ pseo.src.cities.name }} vs {{ pseo.src.cities.name.2 }}Because data rows come from imports, pseo values are sanitized for where they are printed:
Output position | What happens to a value |
|---|---|
Text (titles, slugs, SEO texts) | Tags stripped; |
HTML content | Cleaned with |
Inside an HTML tag or a block comment | Tags stripped and attribute-escaped; brackets encoded |
Raw (no pSEO context set) | Unchanged |
Every { that is followed by another { and every } that is followed by another } in a value gets a space after it ({{ x }} in a CSV cell becomes { { x } }), so data can never become a template.
Limits, source setup and the full workflow are in the Programmatic SEO documentation.
fn: functions
fn is not a data namespace. fn.name(...) calls a built-in function; see Filters and functions.
Still stuck? Contact support