Jump to content

Embed (almost) anything with a website field on steroids (WordPress)


Alejandro

Recommended Posts

WordPress comes with an embed shortcode that allows you embedding almost anything in posts (videos, music, social media feeds). If there's a Joomla plugin that offers a similar functionality via shortcodes/plugin tags, then you can try a similar approach.

You can find the complete list of supported sites here https://wordpress.org/support/article/embeds/#list-of-sites-you-can-embed-from

To take advantage of this functionality in JReviews listings using a website field. Just add the following code in the PHP output format:

return $GLOBALS['wp_embed']->run_shortcode('[embed]'.$value.'[/embed]');

That's it. Now you can embed anything from the list of supported sites. Here's what comes out when I use "https://twitter.com/getJReviews"

image.png

I did make a small edit for this particular output by using the "height" attribute of the embed shortcode. So my code looks like this:

return $GLOBALS['wp_embed']->run_shortcode('[embed  height="300"]'.$value.'[/embed]');

Keep in mind that if this field is open to anyone submitting listings they will be able to paste URLs there for any of the supported sites. If you want to limit the functionality to specific sites you can use the field's validation regex setting. So for example, to limit the field to Twitter embeds only, the regex would look something like this:

^https://twitter.com(.*)

 

Link to comment
×
×
  • Create New...