Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Asgaros

    (@asgaros)

    Hello Liath,

    it is not possible yet to add shortcodes to posts/topics. Can you give me an example of what kind of shortcodes you want to use? Maybe I can implement this functionality in a future release.

    Thread Starter Liath

    (@liath)

    Primary i want to add quickly iframes from pastebin with this shortcode

    i.E.
    [pastebin]YKXi3BZa[/pastebin]

    function pastebin_shortcode( $attr, $content = null ) {
        return '<iframe src = "https://pastebin.com/embed_iframe.php?i=' . $content . '" style = "border:none;width:100%;height:500px;"></iframe>';
    }
    add_shortcode('pastebin', 'pastebin_shortcode');

    i have a lot of codes and scripts there, that i need to add as post

    Plugin Author Asgaros

    (@asgaros)

    I just added a commit to the dev-version which adds a filter hook called asgarosforum_filter_post_content. It will be included in the upcoming v1.0.7 release.

    You can find the patch here:
    https://github.com/Asgaros/asgaros-forum/commit/b942a692391fc7d716c15004778bc2b0d71322c1

    Its just three lines of code which can be easily added by yourself if you need this functionality immediately.

    Thread Starter Liath

    (@liath)

    it works great, now i can add all the shortcodes i want ??

    thank you for your great and fast support

    Hi, Does the tweak above mean that all shortcode can be used in the forum? I have tried adding some shortcodes but it doesn’t work. I have the version that includes the tweak.
    thanks

    Plugin Author Asgaros

    (@asgaros)

    No, you have to hook into the filter function and add the shortcodes you want to use (see code from Liath for example).

    I think I understand now how the hook works. it is to be added as a function to the functions.php file of my theme yes?

    Could you give me help on adding a shortcode function for, say embedding a Youtube video, please?

    I’ve tried hacking Liath’s pastebin function (above) but I’m not very good at coding and need to learn by example.

    hope you can help
    thanks

    Plugin Author Asgaros

    (@asgaros)

    function youtube_shortcode( $attr, $content = null ) {
        return '<iframe width="560" height="315" src="https://www.youtube.com/embed/'.$content.'" frameborder="0" allowfullscreen></iframe>';
    }
    add_shortcode('youtube', 'youtube_shortcode');

    Should be working with this:

    [youtube]u9lwcRffq7c[/youtube]

    Brilliant, Thanks. Although my forum is still outputting just the shortcode when I post a test youtube vid.

    I placed that function code into the functions.php of my theme. I’m assuming I add to the thread.php file something like:
    $post_content = apply_filters('youtube_shortcode', $post_content);

    which I’ve placed below this line in thread.php:
    $post_content = make_clickable(wpautop($wp_embed->autoembed(stripslashes($post->text))));

    alas, no luck so far.

    thanks

    Thread Starter Liath

    (@liath)

    if you have already Version 1.0.7, you don’t have to modify the thread.php

    just put following line in the functions.php of your theme

    add_filter( 'asgarosforum_filter_post_content', 'do_shortcode' );

    then you can use all available shortcodes, or make your own like this

    function youtube_shortcode( $attr, $content = null ) {
        return '<iframe width="560" height="315" src="https://www.youtube.com/embed/'.$content.'" frameborder="0" allowfullscreen></iframe>';
    }
    add_shortcode('youtube', 'youtube_shortcode');

    Thanks for the reply Liath.
    Alas, I can’t get it to work for me. No matter. I’ll either do without shortcodes function or try another forum plugin.

    Thanks for trying to help.

    hmmm, Uninstalled and reinstalled and now youtube embed works!

    thanks for getting this fixed for me ??

    Got another problem unrelated to shortcode / functions which I’ll post on another thread here.

    thanks again

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Use Shortcodes in Thread’ is closed to new replies.