mbr_post
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_page] 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. 'Post 1' is not pulling content from 'Post 2', which itself is pulling content from 'Post 1'.
Parameters
Parameters | Description |
---|---|
id | The post 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_post].
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 post with id 1234:
[mbr_post id='1234' field='post_title']
Returns the value of the field post_content
for the post with id 1234:
[mbr_post id='1234' field='post_content']
Returns the value of the field post_excerpt
for the post with id 1234:
[mbr_post id='1234' field='post_excerpt']
Returns the value of the field post_excerpt
for the post with id 1234 but only if the post_status
for that post is set to publish, otherwise nothing will be returned:
[mbr_post id='1234' field='post_excerpt' status='publish']
Returns the value of the field post_content
for the post with id 1234 but only if the post_status
for that post is set to publish. If the post_content
field is empty then the value of the field post_excerpt
will be returned instead:
[mbr_post 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' ) );