how to add custom widget below post

Posted in: Newsmag
Post count: 30

hello i want to add custom widget to post page(article page), i want to add it just above related posts.
i have this “content.ad” php code : <?php do_action(‘contentad’); ?>

where should i add it i want to make it look like this: http://i.imgur.com/moaRoMS.png
i made above photo with photoshop, i want to place widget exactly like above!

help please, where should i insert that php code?

Post count: 9544

To create a new widget you will need to first register that by creating it in functions.php (see the WordPress codex on how to create new widget areas in a WP theme).

Then you place the code for the widget into the theme template(s) where you wish the widget to appear. You then populate that widget from the appearance > widgets system in WP.

You’d place it in loop-single.php for example, or loop-single-2.php if using post style 2, etc.

For example you might put your custom widget after
<?php echo $td_mod_single->get_author_box();?>

Post count: 30

what if i directly add this code: <?php do_action(‘contentad’); ?>
to loop-single-7.php or comments.php?

is there any easier way to do it? i am familiar with css and html but not php, please help!

Post count: 21

I want to add something similar to my website so it would be great to know the solution.

Post count: 6600

Hi,

You can use the do_shortcode() function and use the shortcodes generated by the Visual Composer plugin to customize the widgets/blocks you want to add into the template and then add it where you want it like this: http://screencast.com/t/Y3TQLaFOx3lP
Hope this helps!

Thanks

Post count: 30

@lucian thanks for responding, can you please elaborate this process?
as far from your above point, i understood these things:
1. go to setting>visual composer> myshort codes ? is it how to generate short codes? but what should i add there to generate code there? i want to add content.ad widget php code.

2. then add <?php echo do_shortcode(‘[]’);?> to loop-single.php like this:
<?php echo $td_mod_single->get_social_sharing_bottom();?>
<?php echo $td_mod_single->get_next_prev_posts();?>
<?php echo do_shortcode(‘[]’);?>
<?php echo $td_mod_single->get_author_box();?>
<?php echo $td_mod_single->get_item_scope_meta();?>
</footer>

as i want my widget to show up just below nest prev navigation?

is this the way you are saying?
if yes then please tell me how to generate short codes and how to use them in details, that would be really great help for those who are new to wordpress!

thank you!

Post count: 6600

Hi,

You can generate a shortcode using the page builder on a page, add the widget you want and customize it as you like, then switch to classic mode and get the shortcode you have in the post editor and add it into the function and place it into the template. You also have some screenshots below so that you can better understand this:

* http://screencast.com/t/XenIUYOL
* http://screencast.com/t/sZV4uZnF9P4r
* http://screencast.com/t/g1FeHElhnUBL
* http://screencast.com/t/ga0UXi4YD5r

Thanks

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newsmag’ is closed to new topics and replies.