Forums

Customizing widgets called by shortcodes (5 posts)

  1. pcgs51
    Member
    Posted 1 year ago #

    Widgets when used via the dashboard will allow various customizations. For instance if I want to not use a title above the widget, I just leave the widget's title box blank. Or I can choose how many post titles to display in the Recent Posts widget.

    But I'm adding widgets to parts of my WordPress site via a script in my functions.php that allows them pretty much anywhere via a shortcode. Problem is I need to know what parameters are available for any given widget and how to call it in the shortcode. For example, this shortcode works in my page:

    [widget widget_name="WP_Widget_Recent_Posts"]

    But how do I control the number of posts? How can I make the title "Recent Posts" not appear. Nothing I've tried works. For example, this doesn't work.

    [widget widget_name="WP_Widget_Recent_Posts" title=""]

    Where can I learn how to affect customizations on widgets via shortcodes? Thanks.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    But I'm adding widgets to parts of my WordPress site via a script in my functions.php that allows them pretty much anywhere via a shortcode.

    without seeing the script, it is impossible to comment on your issue.
    please follow http://codex.wordpress.org/Forum_Welcome#Posting_Code when posting code.

  3. pcgs51
    Member
    Posted 1 year ago #

    Doing it right now. I'll be back soon. Thanks for responding and posting the link.

  4. pcgs51
    Member
    Posted 1 year ago #

    Here is the code via PasteBin: http://pastebin.com/AJJmsmU2

  5. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    http://codex.wordpress.org/Shortcode_API
    http://codex.wordpress.org/Function_Reference/the_widget

    you possibly need to add more attributes to your shortcode, and use them in the 'the_widget()' section of the code.

    http://pastebin.com/AgsLdUAs
    (warning: totally untested - idea for 'recent post widget' only; if it works it would need to be expanded to cover all known widgets)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.