• Home
  • Plugins
    • Use Any Font
      • Use Any Font API Key
    • WP Masonry Layout
    • Jquery Validation For Contact Form 7
    • Real Email Checker
    • Any Mobile Theme Switcher
    • Block Specific Plugin Updates
    • Featured Image in RSS Feed
    • Add Tags And Category To Page
    • Remove Admin Bar For Client
  • Manage API
  • Support Forum
  • Blog
  • Contact
  • Home
  • Plugins
    • Use Any Font
      • Use Any Font API Key
    • WP Masonry Layout
    • Jquery Validation For Contact Form 7
    • Real Email Checker
    • Any Mobile Theme Switcher
    • Block Specific Plugin Updates
    • Featured Image in RSS Feed
    • Add Tags And Category To Page
    • Remove Admin Bar For Client
  • Manage API
  • Support Forum
  • Blog
  • Contact

Blog

  • You are here:
  • Home
  • Add widgets from shortcode in post/page

Add widgets from shortcode in post/page

  • Posted by Dinesh
  • On May 3, 2011
  • In Web Developement, Wordpress
  • 0

WordPress Widgets can be easily customized and used in your theme using dynamic_sidebar(‘WIDGET NAME’) function. But when the time comes to use it in page or post it is not that easy. As the page and post only accepts shortcodes,  you need to write a shortcode which will get contains from widgets. Below you can see steps to call widgets from shortcode.

1. Register A Sidebar


register_sidebar(array(
'name'			=> 'My Sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));

2. Create a function to read sidebar


function get_my_sidebar($output) {
ob_start();
dynamic_sidebar('My Sidebar');
$output = ob_get_contents();
ob_end_clean();
return $output;

3. Create Shortcode


add_shortcode('sidebar_shortcode','get_my_sidebar');


4. Use it
Use


[sidebar_shortcode]

in post/page to get the widgets assigned in sidebar.

Note
Use these codes in functions.php of your active theme.

TAGS: shortocode widgets
Share:

Previous Post

How to use any font without image?

Next Post

Exclude Page From Wordpress Search
0 comments on Add widgets from shortcode in post/page
Our Plugin
  • Use Any Font
  • WP Masonry Layout
  • Jquery Validation For Contact Form 7
  • Real Email Checker
  • Any Mobile Theme Switcher
  • Block Specific Plugin Updates
  • Featured Image in RSS Feed
  • Add Tags And Category To Page
  • Remove Admin Bar For Client
Support Forum
  • Add Tags And Category to Page and Post Types
  • Any Mobile Theme Switcher
  • Block Plugin Updates
  • Email Checker
  • Featured Image in RSS Feed
  • Jquery Validation for Contact Form 7
  • Use Any Fonts
Scroll
Support Forums
  • Add Tags And Category to Page and Post Types
  • Any Mobile Theme Switcher
  • Block Plugin Updates
  • Email Checker
  • Featured Image in RSS Feed
  • Jquery Validation for Contact Form 7
  • Use Any Fonts
Recent Topics
  • Can this be used with WordPress Oxygen
  • Why I can not load font?
  • Font not working
  • Website adress changed & API
  • Problem with font display on iPhones only
  • Specify a cache validator
  • Re-Generated Test API Fails, Can Only Use Once Even When Re-generated?
Testing Platform Partner
Header logo

 

Become An Affiliate

Promote Us and Get 30% commission in referral.

Become An Affiliate Now !

@2018 © Dnesscarkey