wp.get
/ Core / wp.get
Title | : | wp.get | ||
Purpose | : | To get the WordPress specific values of posts, users, taxonomy etc. It is a general-purpose shortcode. | ||
Syntax | : |
|
||
Input Parameters | : | default: used to return default value in case of wp.get does not returns any values. | ||
Return Value | : | depends on the parameters specified, check the examples below. | ||
Example | : | see various examples and supported parameters below. |
Examples:
To get the attachment URL
1 |
[wp.get attachment_url attachment_id='{template.data.image}' /] |
To get the Alternate text set for media
1 2 3 |
[wp.get image_alt attachment_id='1126445' /] [wp.get image_alt post_id='1181341' /] |
To get the details of an attachment
1 |
[wp.get attachment attachment_id='1126445' o.dump=true /] |
To get breadcrumbs in the single post page
1 2 3 |
[wp.get breadcrumb seperator='--' show_home='yes' /] [wp.get breadcrumb show_home='no' /] |
To get the next post, the previous post of a given post
1 2 3 4 5 6 7 8 9 10 11 |
[wp.get next_post post_id='1045833' /] //returns post id of next post [wp.get next_post.url post_id='1045833' in_same_cat='true' /] [wp.get next_post.slug post_id='1045833' in_same_cat='true' take_all_post='yes'] [wp.get prev_post post_id='1045833' /] //returns post id of previous post [wp.get prev_post.url post_id='1045833' in_same_cat='true' /] [wp.get prev_post.slugpost_id='1045833' in_same_cat='true' take_all_post='yes'] |
To get widgets registered within the sidebar
1 |
[wp.get sidebar.sidebar-primary /] |
To get options saved with WordPress
1 2 3 |
[wp.get option.<key> /] //key of of the option you want the value of [wp.get option.date_format /] |
To sideload a media to post and get the updated URL
1 |
[wp.get sideload_media url='http://www.getawesomestudio.com/wp-content/uploads/2017/02/ux-788002_1920.jpg' post_id='1181341' /] |
To access wpdb object, especially for getting table prefix etc.
1 |
[wp.get wpdb dump=true /] |
To access global post object
1 |
[wp.get post dump=true /] |
To access active wp_query object
1 |
[wp.get wp_query dump=true /] |
To access the details for currently logged in user
1 2 3 |
[wp.get current_user dump=true /] [wp.get current_user.data.user_login dump=true /] |
To get the link of a term
1 |
[wp.get term_link taxonomy='category' slug='emi-free-loan' /] |
To access the term meta of a taxonomy term
1 |
[wp.get term_meta term_id='143' key='agent-email-id' dump=true /] |
To generate a nonce
1 |
[wp.get nonce.bingo_angle dump=true /] //bingo angle is the key for which nounce wil be greated and saved against. |
To verify the nonce
1 |
[wp.get denonce.9690801b57::bingo_angle dump=true /] |
To get all the terms attached to a post
1 |
[wp.get taxonomy_term_list post_id='1045833' /] |