I've created a super simple contact page template, just content and a contact form, like so:
<?php
/*
Template Name: Contact
*/
?>
<?php while (have_posts()) : the_post(); ?>
<div id="blockcontact">
<?php the_content(); ?>
<form id="contactform" method="post" action="<?php bloginfo('template_directory'); ?>/_assets/submitemail.php">
<input name="user" type="text" value="Name" />
<input name="email" type="text" value="E-Mail"/>
<input name="url" type="text" value="Website" />
<input name="subject" type="text" value="Subject" />
<textarea rows="10" name="message" cols="50" id="message">Your message here...</textarea>
<input type="submit" class="button" value="SEND" id="send" />
<div id="error"></div>
</form>
</div><!-- blockcontact -->
<?php endwhile; ?>
I then need to insert this page into another page (say, homepage) - using custom query. The query is irrelevant, I think, but it's basically getting all created pages and displaying their contents:
<?php
$temp_query = $wp_query;
$args = array('post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_status' => 'publish', 'posts_per_page' => 5,);
$wp_query = new WP_Query($args);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="block group" id="<?php echo $post->post_name; ?>">
<?php the_content(); ?>
</div><!-- /<?php echo $post->post_name; ?> -->
<?php endwhile; ?>
<?php endif; ?>
<?php $wp_query = $temp_query; ?>
It seems to work fine for normal pages (those without a custom template), but for this contact page, I'm getting from the query is the content (the_content()
) but not the form.
I also have another custom page template that I'm trying to pull into the homepage, and it's doing the same thing.
Any idea what would cause this problem? Never seen anything like that and I've been working with WordPress for years now...
Thanks in advance!
EDIT: I now see my problem - the_content()
in my query works correctly - it pulls the entered content of the page. What I'm trying to achieve is get the entire content of the page, including my custom HTML, much like include()
function in PHP. Would love some tips on how to do that.