Skip to content

Internal Shortcode | [Post_Title]

EkoJr edited this page Jan 3, 2017 · 2 revisions

Description

Adds the Post Title.

Usage

[post_title]

Return

(string) WP_Post->Post_Title.

Examples/Sample

Example 1

[post_title]

Returns

Title Example

Source

File: advanced-post-list/includes/class/apl_shortcodes.php

/**
 * Post Title Shortcode. 
 * 
 * Desc: Adds the post/page title.
 * 
 * 1. Add to return Post Post_Title.  
 * 2. Return string. 
 * 
 * @since 0.1.0
 * @version 0.4.0 - Changed to Class function, and uses WP's built-in
 *                  functions for setting default attributes & do_shortcode().
 * 
 * @param array $atts
 * @return string Post->post_title.
 */
public function post_title($atts)
{
    //INIT
    $atts_value = shortcode_atts( array() , $atts, 'post_title');
    $return_str = '';
    
    //STEP 1
    $return_str .= htmlspecialchars($this->_post->post_title);
    
    //STEP 2
    return $return_str;
}

Additional Resources

Clone this wiki locally