WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Shortcode Help (5 posts)

  1. wp_dilettante
    Member
    Posted 4 years ago #

    I am new to WordPress and do not know PHP. I recently learned about shortcodes in WP and was wondering if there is a shortcode which I can use to assign tag(s) to a post by using the shortcode from within the post content.

    Thanks.

  2. MichaelH
    Member
    Posted 4 years ago #

    Use this plugin:
    http://wordpress.org/extend/plugins/template-tag-shortcodes/

    And this shortcode

    [the_tags]
  3. wp_dilettante
    Member
    Posted 4 years ago #

    Thank you for the suggestion. If I understand correctly, the 'template-tag-shortcodes' plugin has a list of shortcodes that only get information about a post but do not assign information to it. The shortcode in the plugin called [the_tags] uses the WordPress function the_tags(). Then, according to the Codex here the shortcode will only list the tags the post already belongs to.

    What I would like to accomplish is this:
    1. Send an email to my WordPress blog.
    2. The body of the email contains a shortcode (for e.g. [set_tags a,b,c]).
    3. WordPress processes the email and publishes it as a post and assigns it tags a, b and c even if no such tags already exist.

    Which WordPress function would accomplish this? Would wp_set_post_tags() work?

  4. MichaelH
    Member
    Posted 4 years ago #

  5. wp_dilettante
    Member
    Posted 4 years ago #

    Ah! The function wp_insert_post might very well work, not only for assigning tags to the post but also assigning other information to it. Perhaps the shortcodes mentioned on the WordPress.com page uses this function too. Now I have to figure out how to write the appropriate shortcodes.

    Before seeing your reply I had stumbled upon the function wp_add_post_tags here on row 2018 and had written this shortcode for it:

    function wp_add_post_tags($post_id->ID, $tags=''){
           return wp_set_post_terms($post_id,$tags,'post_tag',$append);
    }
    add_shortcode('my_tags', wp_add_post_tags)

    I had not implemented it. So I don't know if it would even work.

    Anyway, thanks again for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags