Skip to content

Internal Shortcode | [Post_Permalink]

EkoJr edited this page Mar 16, 2017 · 4 revisions

Description

Post Permalink (URL) Shortcode associated with WP's Permalink configuration (Settings->Permalinks) for WP_Post Objects.

Usage

[post_permalink]

Return

(string) Permalink/URL from WP_Post ID.

Examples/Sample

Example 1

[post_permalink]

Returns

http://example.com/.../post_slug

Source

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

/**
 * Post Permalink (URL) Shortcode. 
 * 
 * Desc: Adds the post/page permalink/URL.
 * 
 * 1. Get & Add to return Post's Permalink.  
 * 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 Permalink associated with Post ID.
 */
public function post_permalink($atts)
{
    $atts_value = shortcode_atts( array() , $atts, 'post_permalink');
    
    $return_str = '';
    $return_str .= get_permalink($this->_post->ID);
    
    return $return_str;
}

Additional Resources

Related

[guid] - WP Default URL.

Clone this wiki locally