Skip to content

Internal Shortcode | Post_Slug

EkoJr edited this page Jan 3, 2017 · 4 revisions

Description

Adds the Post Slug (post_name). Alias to [post_name]

Usage

[post_slug]

Return

(string) WP_Post->Post_Name.

Examples/Sample

Source

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

/**
 * Post Slug Shortcode
 * 
 * Desc: Adds the Post Slug from WP_Post->post_name.
 * 
 * 1. Add to return the Post Post_Name.  
 * 2. Return string.  
 * 
 * @since 0.4.0
 * 
 * @param array $atts
 * @return string Post->post_name.
 */
public function post_slug($atts)
{
    //INIT
    $atts_value = shortcode_atts( array() , $atts, 'post_slug');
    $return_str = '';
    
    //STEP 1
    $return_str .= $this->_post->post_name;
    
    //STEP 2
    return $return_str;
}

Additional Resources

Clone this wiki locally