Forums

[resolved] Plugin shortcode after post loads (2 posts)

  1. LoganSix
    Member
    Posted 3 years ago #

    I am creating a new plugin that uses shortcode for two items. One for each individual item and then another to combine links to the individual items.

    i.e.
    [summary]
    [item id="1"]
    [item id="2"]
    [item id="3"]
    [item id="4"]

    If I add the [summary] tag at the start of the post, it doesn't get the values from the items. If I add it after the items, it get each of the items afterward. However, I want the [summary] shortcode to appear at the top of the post and not at the bottom.

    Any ideas? I tried to add the function at "end_loop", but that didn't work.

  2. LoganSix
    Member
    Posted 3 years ago #

    Okay, I figured it out!!

    I created a function to add the shortcode after the content is called.

    function my_shortcode($content) {
    		   add_shortcode('myshortcode', array(&$this, 'myshortcodefunction'));
    		   return do_shortcode($content);
    		}

    Then I added the function as an action

    add_action('the_content', array(&$this, 'my_shortcode'), 11);

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.