I’d be most grateful if someone could help me out here. I’d like to call a shortcode in a echo section, in a php file on my WordPress site. I’ve tried a few things but nothing seems to work.

Here is the current code (working)

<?php
if ( is_home() or is_front_page()) {echo '<div class="section group">
            <div class="col span_1_of_2">
                <a href="http://www.ptmagazine.co.uk/testsite/"><img src="http://www.ptmagazine.co.uk/testsite/wp-content/uploads/2013/12/PT-Magazine-Web-Logo.jpg"></a>
            </div>
            <div class="col span_1_of_2">
        <a href="http://www.focus-training.com/"><img src="http://www.ptmagazine.co.uk/testsite/wp-content/uploads/ads/header.jpg" /></a>
            </div>
        </div>
</div>
</div>' ; }

I’d like to replace the below bit with a shortcode

<a href="http://www.focus-training.com/"><img src="http://www.ptmagazine.co.uk/testsite/wp-content/uploads/ads/header.jpg" /></a>

I’ve tried the usual

<?php echo do_shortcode("[shortcode]"); ?>

but I end up with nothing where the shortcode should appear

Also tried escaping the html with ‘ ‘ marks just before and after the shortcode call but the page then fails to load.

I’ve added the shortcode to a page here http://www.ptmagazine.co.uk/testsite/about-us/ (its the focus-training image at the top of the page, not the one in the header) and if I view source and copy the html for the shortcode and then put it in my php file all works well.

Any assistance greatly appreciated.
Thanks

Read more here: Using a combination of html and php in an echo in a php file (wordpress)


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: