Advanced WordPress widgets with Pods

Even if you are not a PHP guru, you can feel the power of Pods with simple WordPress features as widgets and shortcodes.

(for french visitors, you can read this in french , for Shakespeare.. sorry 😉 

Lot of premium themes use (and abuse) widgets and shortcodes, but if your needs don’t fit with all features coded by the developer you will be armless with poor « text widget »…

How to add image, link, list… on widget ? Why it’s not easy as writing article ?

With Pods… it will be !

You can write 2 types of widgets : WYSIWYG widget or Template widget

WYSIWYG widget

It’s the most simple widget, you just need a Pod with a WYSIWYG ( Visual Editor) field, and show it on your widgets area with a shortcode.

WordPress doesn’t allow shortcode in widgets by default, you have change it,

by yourself, with a single line in « functions.php » file from your theme.

add_filter('widget_text', 'do_shortcode');

Or with another plugin as Shortcode Widget.

Then you can add a simple text widget with this code

[pods name="widget_wysiwyg" id="1"]{@my_content}[/pods] 

or

[pods name="widget_wysiwyg" slug="pods-super"]{@my_content}[/pods]

For further information about shortcode in Pods : Shortcode in Pods

Template widget

If you need a structured widget to fit with your design or to show a Google Map for example, you should use template widget.

Instead of a single content field, you will create a field for each data you have to display. For example to display a product : a name (Plain text), a pics ( File Image), a description and a link (Plain text).

Create a template on Pods (you may have to activate a component), it could look like :

<a href="{@link}">{@image}</a>
<br/>
<a href="{@link}">{@name}</a>
<br/>
{@description}

Then you can display your pod with this shortcode:

[pods name="widget_template" template="my_template" id="1"]

More features…

Saved widget

When you update a widget, the old version is lost, with pods, you change have to change shortcode, all datas are saves in pods, if you want to display anither product, you need only change Id. For Christmas, you can create a « Christmas widget », display few days, and switch later to the « normal » widget.

List widget

To display your 3 best sellers products :

[pods name="widget_template" limit="3" template="my_template" orderby"sales"]

Rotative widget

To display one randomize product

[pods name="widget_template" limit="1" template="my_template" orderby"RAND()"]

They are just examples to show you the power of Pods for widget, let your imagination start !

If you need more features, you should look at this plugin : Dynamic Widget (fully compliant with Pods)

Laisser un commentaire