1. Home
  2. Using Blocs
  3. Wordpress
  4. WordPress Short Codes

WordPress Short Codes

Blocs Plus supports a range of WordPress specific short codes that can be used within the content of text Brics, custom data attributes, custom Brics and URL interactions. When a project is exported as a WordPress theme, these codes are replaced with WordPress PHP functions.

Site Codes

Site Name

%WP_name% – This will be populated with the blog name that is assigned via the WordPress admin (<?php bloginfo('name'); ?>). Known in the WordPress backend (General Settings) as the Site Title.

Site Details

%WP_description% – This will be populated with the blog description that is assigned via the WordPress admin (<?php bloginfo('description'); ?>). Known in the WordPress backend (General Settings) as the Tagline.

Login URL

%WP_login% – This will be populated with the WordPress login URL (<?php echo wp_login_url(); ?>).

Page & Post Details

Page Title

%WP_title% – This will be populated with the current page/post title (<?php the_title(); ?>).

Page Content

%WP_content% – This will be populated with the current page/post content (<?php the_content(); ?>).

Excerpt

%WP_excerpt% – This will be populated with the current page/post excerpt (<?php the_excerpt(); ?>).

Category

%WP_category% – This will be populated with the first category name for the current post (<?php echo get_the_category()[0]->name;?>).

Category URL

%WP_categoryURL% – This will be populated with the first category URL for the current post (<? php echo get_category_link( get_the_category()[0] );?>).

Categories

%WP_categories% – This will be populated with a list of all category text links, separated by a comma, for the current post (<?php echo the_category(', ') ;?>).

Tag

%WP_tag% – This will be populated with the first tag name for the current post (<?php $tags = wp_get_post_tags($post->ID); echo $tags[0]->name;?>).

Tag URL

%WP_tagURL% – This will be populated with the first tag URL for the current post (<?php $tags = wp_get_post_tags($post->ID); echo get_tag_link( $tags[0]->term_id ); ?>).

Tags

%WP_tags% – This will be populated with a list of all tag text links, separated by a comma, for the current post (<?php echo get_post_tag_links(', ');?>).

Publish Data

%WP_publishDate% – This will be populated with the current page/post publish date (<?php echo get_the_date(); ?>).

Edit Date

%WP_editDate% – This will be populated with the current page/post edit date (<?php echo the_modified_date(); ?>).

Edit Post URL

%WP_editPostURL% – This will be populated with the current page/post edit admin URL (<?php echo get_edit_post_link( get_the_ID()); ?>).

Comment Count Number Only

%WP_commentCount% – This will be populated with the current post comment count (<?php echo get_comments_number(); ?>).

Comment Count With Label

%WP_commentCountFull% – This will be populated with the current post comment count followed by the word comment(s) (<?php echo get_comments_number(); ?> Comment<?php if (get_comments_number() != 1){echo \"s\";} ?>).

Post & Page Images

Thumbnail URL

%WP_thumbURL% – This will be populated with the current page/post thumbnail URL (<?php echo get_the_post_thumbnail_url(); ?>).

Small Thumbnail URL

%WP_thumbSmURL% – This will be populated with the current page/post small thumbnail URL (<?php echo get_the_post_thumbnail_url(null, 'thumbnail'); ?>).

Medium Thumbnail URL

%WP_thumbMedURL% – This will be populated with the current page/post medium thumbnail URL (<?php echo get_the_post_thumbnail_url(null, 'medium'); ?>).

Large Thumbnail URL

%WP_thumbLgURL% – This will be populated with the current page/post large thumbnail URL (<?php echo get_the_post_thumbnail_url(null, 'large'); ?>).

Full Thumbnail URL

%WP_thumbFullURL% – This will be populated with the current page/post full thumbnail URL (<?php echo get_the_post_thumbnail_url(null, 'full'); ?>).

Thumbnail Title

%WP_thumbTitle% – This will be populated with the current page/post thumbnail title content. Data is set in the WordPress Media Library backend. (<?php echo get_post(get_post_thumbnail_id())->post_title; ?>).

Thumbnail Caption

%WP_thumbCaption% – This will be populated with the current page/post thumbnail caption content. Data is set in the WordPress Media Library backend. (<?php echo get_the_post_thumbnail_caption(); ?>).

Thumbnail Description

%WP_thumbDesc% – This will be populated with the current page/post thumbnail description content. Data is set in the WordPress Media Library backend. (<?php echo get_post(get_post_thumbnail_id())->post_content; ?>).

Archives

Archive Title

%WP_archiveTitle% – This will be populated with the current archive page title (<?php echo the_archive_title();?>).

Archive Description

%WP_archiveDesc% – This will be populated with the current archive page description (<?php echo get_the_archive_description(); ?>).

Current Search Query

%WP_searchQuery% – This will be populated with the current search term as text (<?php echo get_search_query(); ?>).

Query Count

%WP_postQueryCount% – This will be populated with the current number of items found for the current page content loop (<?php echo $wp_query->found_posts; ?>).

Author

Author Avatar

%WP_authorAvatarURL% – This will be populated with the current page/post author thumbnail (200px) URL (<?php echo get_avatar_url(get_the_author_meta('ID'),array('size' => 200));?>).

Author Avatar Medium

%WP_authorMdAvatarURL% – This will be populated with the current page/post author thumbnail (500px) URL (<?php echo get_avatar_url(get_the_author_meta('ID'),array('size' => 500));?>).

Author Avatar Large

%WP_authorLgAvatarURL% – This will be populated with the current page/post author thumbnail (1000px) URL (<?php echo get_avatar_url(get_the_author_meta('ID'),array('size' => 1000));?>).

%WP_link% – This will be populated with the current page/post URL (<?php echo get_permalink(); ?>).

Previous Post Link

%WP_prev_post_link% – This will be populated with a text link to the previous post (<?php previous_post_link( '%link', '%title' );?>).

Next Post Link

%WP_next_post_link% – This will be populated with a text link to the next post (<?php next_post_link( '%link', '%title' );?>).

Previous Post URL

%WP_prev_postURL% – This will be populated with the URL of the previous post (<?php echo get_permalink( get_adjacent_post(false,'',false)->ID );?>).

Next Post URL

%WP_next_postURL% – This will be populated with the URL of the next post(<?php echo get_permalink( get_adjacent_post(false,'',true)->ID );?>).

Author Details

Author

%WP_author% – This will be populated with the current page/post author name (<?php the_author(); ?>).

%WP_authorLink% – This will be populated with a link to the authors post page (<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>).

Author Email

%WP_authorEmail% This will be populated with the current page/post author email (<?php echo $current_user->user_email; ?>).

Author First Name

%WP_authorFirstName% This will be populated with the current page/post author first name (<? php echo $current_user->user_firstname; ?>).

Author Last Name

%WP_authorLastName% This will be populated with the current page/post author last name (<? php echo $current_user->user_lastname; ?>).

Author Bio

%WP_authorBio% – This will be populated with the current page/post author bio content (<?php echo $current_user->user_description; ?>).

Author Website

%WP_authorWebsite% – This will be populated with the current page/post author website URL (<?php echo $current_user->user_url; ?>).

Author Display Name

%WP_authorDisplayName% – This will be populated with the current page/post author display name (<?php echo $current_user->display_name; ?>).

Logged In User

User Name

%WP_userName% – This will be populated with the logged in user name (<?php echo $current_user->user_login; ?>).

User Email

%WP_userEmail% This will be populated with the logged in user email (<?php echo $current_user->user_email; ?>).

User First Name

%WP_userFirstName% This will be populated with the logged in users first name (<?php echo $current_user->user_firstname; ?>).

User Last Name

%WP_userLastName% This will be populated with the logged in users last name (<?php echo $current_user->user_lastname; ?>).

User Bio

%WP_userBio% – This will be populated with the logged in users bio content (<?php echo $current_user->user_description; ?>).

User Website

%WP_userWebsite% – This will be populated with the logged in users website URL (<?php echo $current_user->user_url; ?>).

Display Name

%WP_userDisplayName% – This will be populated with the logged in users display name (<?php echo $current_user->display_name; ?>).

Custom Field Data

To display post and page custom field data use the following short code. Take care to add your custom field name within the brackets of the short code and make sure you add the custom field type to your project via the WordPress Custom Data Manager (Main Menu > Window > WordPress Custom Data Manager).

%WP_CustomField(custom field name here)% This will be populated with the custom field content set for the post or page (<?php echo get_post_meta(get_the_ID(), ‘field name', TRUE);?>).

Updated on 14th November 2023

Was this article helpful?

Related Articles