Mini Loops
[resolved] Adding Shortcodes ? (3 posts)

  1. sugardaddy
    Posted 4 years ago #

    I'm trying to add some new shortcodes but it's not interpreted.
    In fact, I'm using KIA Subtitle which add a subtitle field (just under the title and that's better for my user than a custom field) and is accessible with the_subtitle or get_the_subtitle functions.
    I know I could achieve that with custom fields... but I'm curious to know why my try failed. Here is the code I add to helpers.php :

    add_shortcode( 'ml_subtitle' , 'miniloop_subtitle' );
    function miniloop_subtitle( $atts ) {
    	extract( shortcode_atts( array(
    		'length' => 0, //characters
    		'before' => '',
    		'after' => '',
    	), $atts ) );
    	$subtitle = apply_filters( 'the_subtitle', get_the_subtitle() );
    	if ($length)
    		$subtitle = substr( $subtitle, 0, $length );
    	$subtitle = $before . $subtitle . $after;
    	return $subtitle;

    Thanks for your help !


  2. sugardaddy
    Posted 4 years ago #

    any idea ? (back from vacation)

  3. sugardaddy
    Posted 3 years ago #

    This code is incorrect... I forget something very important.

    $subtitle = apply_filters( 'the_subtitle', get_the_subtitle($post_id) );

    It works like a charm !

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Mini Loops
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic