aminabbasian
Member
Posted 2 years ago #
Hey Guys,
I've put together a site which works as a Coda style slider. With each page called using the Get Page function such as:
<?php
$page_id = 7;
$page_data = get_page( $page_id );
$content = $page_data->post_content;
$title = $page_data->post_title;
echo $page_data->post_content;
?>
However I do have one issue where contact form 7 is not showing. all that is shown is [contact-form 1 "contact"].
There doesn't seem to be any plugin conflicts.
Any ideas?!
thanks
You're displaying raw page content ($page_data->post_content) instead of filtered/process content( the_content()).
aminabbasian
Member
Posted 2 years ago #
Thanks Esmi,
I've tried the following:
<?php if( !is_page('7') ) :?>
<?php else the_content();
<?php endif;?>
but with no luck. This causes an error and blank page.
Am I going on the right direction?
Try using get_posts instead?
<?php
$these_pages = get_posts('page_id=7');
foreach($these_pages as $post) :
setup_postdata($post);
the_content();
php endforeach;
?>
aminabbasian
Member
Posted 2 years ago #
same result.
This is my full code:
[Code moderated as per the Forum Rules. Please use the pastebin]
aminabbasian
Member
Posted 2 years ago #
mattyza
Member
Posted 2 years ago #
Hi aminabbasian,
Using your original code snippet, this may be a solution:
<?php
$page_id = 7;
$page_data = get_page( $page_id );
$content = apply_filters( 'the_content', $page_data->post_content );
$title = $page_data->post_title;
echo $content;
?>
Essentially, to render shortcodes, etc, the filters on the_content need to be applied.
More on this is available at: http://codex.wordpress.org/Function_Reference/apply_filters
I hope this helps. :)
All the best,
Matty.
aminabbasian
Member
Posted 2 years ago #
perfect! Worked a treat!
many thanks