WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Content Slide
[resolved] Added shortcode support (8 posts)

  1. bradvin
    Member
    Posted 3 years ago #

    Thanks for an awesome slider plugin! One thing I needed was shortcode support so that I didnt need to edit the php theme files to add the slider to a page. All i did was add this 1 line of code to the plugin at line 108:

    add_shortcode('wpcs', 'wp_content_slider');

    now in the editor simply use the shortcode:

    [wpsc]

    and you are sorted :) Maybe you can add this into a future version?
    cheers
    Brad

    http://wordpress.org/extend/plugins/content-slide/

  2. emidesigns
    Member
    Posted 3 years ago #

    Hey Brad, cheers for your fix!

    My only suggestion, change the post to read:

    [wpcs]

    The Short code works wonders.

    e.

  3. snilesh
    Member
    Plugin Author

    Posted 2 years ago #

    Hi Brad,
    Yes nice fix. Now days i am busy with my work so not able to update this plugin. But i will add your code in next release

  4. exposedesign
    Member
    Posted 2 years ago #

    This works but if you want to place the shortcode in a specific place on a post/page (and not just at the top) you will need to add output buffering to the wp_content_slider() function:

    Before anything is echoed (around line 492) add:

    ob_start();

    And just before the closing } of the function add:

    $output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;
  5. CockpitSeeker
    Member
    Posted 2 years ago #

    Nice trick Brad.

    I'm suggesting something else:
    what if someone wants to post different slides (i.e slides with different image sources) in different places. Would that be hard to implement? (I'm looking at it...)

    Example of interesting use:

    • I chose to display [wpcs1] in my homepage for advertisement
    • I chose to display [wpcs2] in my portfolio to show my last holidays in Cancun

    How does that sound?

  6. crownoflyfe
    Member
    Posted 2 years ago #

    where does this bit go? in a Post or part of the theme?

    exposedesign
    Member
    Posted 3 months ago #

    This works but if you want to place the shortcode in a specific place on a post/page (and not just at the top) you will need to add output buffering to the wp_content_slider() function:
    ob_start();

    $output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;

    ----just a little lost HELP

  7. rjpalombo
    Member
    Posted 2 years ago #

    Crownoflyfe:

    Open the Content_Slide.php file

    Search for the function "function wp_content_slider()" around line 254.

    Somewhere before the first "echo" command copy/paste: ob_start();

    After that scroll all the way to just about the end of the file somewhere around 342 I put:

    $output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;

    Bradvin & exposedesign: Excellent work! Those are two nice additions to snilesh's work.

    snilesh, nice job on this plugin. I agree that these two functions should be in a future release.

  8. SBonse
    Member
    Posted 2 years ago #

    I must be doing something wrong. I cannot get rjpalombo's suggestion to work.
    I'm pretty new at this, I don't understand exactly where you mean "just about the end of the file somewhere" and I have no line 342. I feel like such a dork for posting that! hahah

    I must be doing something wrong. I cannot get rjpalombo's suggestion to work.
    I'm pretty new at this, I don't understand exactly where you mean "just about the end of the file somewhere" and I have no line 342. I feel like such a dork for posting that! hahah

    *EDIT* Never mind, I spoke too soon, sorry about that!
    I got it to work. For other users, follow the directions step by step from the first post down to what rjpalombo posted (if you want the slider to appear wherever you paste the short code)

    The last bit of code: $output_string = ob_get_contents();
    ob_end_clean();
    return $output_string;

    Needs to go at the very bottom of the PHP file between the last <? php } ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic