get_the_content() inside a custom template is getting blog posts
-
Hello,
I created a theme. It has custom template for pages. For example:
<?php /* Template Name: Page Home */?>
is my homepage.
All the custom templates are working fine. The content I put in the template php files shows well.
But in the homepage I need to do something similar I did in the FAQ page.
<?php echo do_shortcode(the_content()); ?>
The above in the FAQ collects the faq shortcode:
function faq_shortcode($atts, $content = null) { return do_shortcode($content); } add_shortcode('faq', 'faq_shortcode');
And all is fine there.
But when I put
<?php echo do_shortcode(the_content()); ?>
in the homepage template file, instead of showing the content of the shortcode I put in the edit mode of that specific page that is using the “Page Home” template, it shows blog posts instead.If I temporarily change the page template to “default template” then all the custom edits go away (obviously), but the short code info show up!
How can I make the
<?php echo do_shortcode(the_content()); ?>
to read the content I put in the page edit mode while using a custom template?FYI:
- For blog posts I have another template which is working fine.
- In settings => appearance I have set the “Page Home” template for home as a static page. And for blog posts I have chosen the blog posts specific template.
Please help
- The topic ‘get_the_content() inside a custom template is getting blog posts’ is closed to new replies.