mbr_page
Usage
This shortcode returns data from a specified page/post record in your WordPress database.
It provides a means of duplicating content on alternate pages/posts with a different set of access conditions but without the need to maintain several content sources.
Furthermore, by allowing content parts to be drawn from several different pages/posts, it extends the content management capabilities of WordPress.
This shortcode is the identical to [mbr_post] and is provided as a means of self-documenting your intentions.
Please excercise care and ensure that you do not create cyclical references e.g. 'Page 1' is not pulling content from 'Page 2', which itself is pulling content from 'Page 1'.
Parameters
Parameters | Description |
---|---|
id | The page ID i.e. post_id for which to return the specified field data.Default: none. Required: yes. |
field | Specifies the name of a WordPress post field to return. Any field used within the WordPress post or post_meta table can be specified. Some Permitted Values: post_title, post_date, post_content, post_excerpt. Default: post_content Required: no. |
status | Specifies the post status required in the post_status field for the returned data to be displayed.Default: none. Required: no. |
excert_fb | Specifies whether a fallback to the excerpt is used if the status is not met. Please note that this ONLY applies when the specified field is set to post_content .Permitted Values: yes, y, true, t, or 1. Default: none. Required: no. |
Validity
This shortcode is evaluated for any type of visitor.
Conditional Branching
This shortcode does NOT support conditional branching with [ELSE_page].
Nesting
Shortcode nesting within is NOT supported.
Examples
- Example 1
- Example 2
- Example 3
- Example 4
- Example 5
Returns the value of the field post_title
for the page with id 1234:
[mbr_page id='1234' field='post_title']
Returns the value of the field post_content
for the page with id 1234:
[mbr_page id='1234' field='post_content']
Returns the value of the field post_excerpt
for the page with id 1234:
[mbr_page id='1234' field='post_excerpt']
Returns the value of the field post_excerpt
for the page with id 1234 but only if the post_status
for that page is set to publish, otherwise nothing will be returned:
[mbr_page id='1234' field='post_excerpt' status='publish']
Returns the value of the field post_content
for the page with id 1234 but only if the post_status
for that page is set to publish. If the post_content
field is empty then the value of the field post_excerpt
will be returned instead:
[mbr_page id='1234' field='post_content' status='publish' excerptfb='1']
API
For direct use in PHP code use the structure as illustrated here:
$my_excerpt = mbr_page( array( 'id'=>'1234', 'field'=>'post_excerpt' ) );