Home>Support>Including the template of a widget within a widget template?

Including the template of a widget within a widget template?

I know I can use for example the button widget in another widget, let’s say a custom hero image. I have both templates, one for the button and one for the hero image. How do I include in the hero image’s template the button’s template??

Here is an example, that makes the problem more understandable:

<div class="hero-inner">
	<div class="hero-text-container <?php echo $instance['text_align']; ?>">
		<h1><?php echo $instance['title']; ?></h1>
		<div class="hero-btn-container">
		    <?php
		        foreach ($instance['buttons'] as $button) {
                            //here I would like to use the button template
			    echo $button; // obviously this doesn't work and getting the template file in a string and echoing it             isn't such a great idea
			
		    }?>
		</div>
	</div>
</div>

Thank you!

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Denislicau,

    Your after siteorigin_panels_the_widget() (example call). Please note that this is the exact code for this so it may be a tad confusing. Your best bet at completely understanding it would be the follow it as it goes (see a function that you don’t know? Find it and see what it does).

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More