Shortcode not working in custom page template
-
Hi,
I have a custom made WP theme and I’m trying to insert a contact form on a page with a custom page template (“template-page.php”). However, it’s not displaying the form – it just displays the shortcode itself: [contact-form-7 id=”12263″ title=”form name”]
The contact form displays when I use the standard page template (page.php). But I need to use the custom page template, otherwise the rest of the page content is not displaying correctly.
I’m guessing something is missing in the template-page.php file:
get_header(); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="wrapper"> <div class="page-content<? if($curpage->post_parent != 0) { echo " subpage"; } ?>"> <div class="cols"> <div class="main-content" style="padding-top: 68px; float: right;"> <?php echo $curpage->post_content; ?> </div> <?php echo '<div class="navbar"><div class="box"><h2>'; if($curpage->post_parent == 0) { echo get_the_title(); } else { $parent = get_page($curpage->post_parent); echo $parent->post_title; } echo '</h2><ul class="nav-list">'; $args = array("sort_column" => "menu_order"); $pages = get_pages($args); foreach ( $pages as $pagg ) { if(($curpage->post_parent == 0 && $pagg->post_parent == get_the_ID()) || ($curpage->post_parent != 0 && $pagg->post_parent == $curpage->post_parent)) { $option = '<li><a '; if(get_the_ID() == $pagg->ID) { $option .= 'class="selected" '; } $option .= 'href="'.get_page_link( $pagg->ID ).'">'; $option .= $pagg->post_title; $option .= ' »</a></li>'; echo $option; } } echo '</ul></div></div>'; ?> <div class="navbar brownbox" style="background-color: #2b2223; clear: left;"><div class="box" style="background-color: #2b2223; padding-bottom: 10px;"> <?=get_post_meta($post->ID, 'brownbox', true);?> </div></div> </div> </div> </div> <script type="text/javascript"> if(jQuery('.brownbox > div').html().replace(/\s/g,'') == '') { jQuery('.brownbox').remove(); } jQuery('#main').css('background-image','url(<?=preg_replace("/^.*?src=\"([^\"]*)\".*?$/","$1",get_the_post_thumbnail( $post->ID, 'big-thumb' ));?>)'); </script> <?php endwhile; ?> <?php else : ?> <div class="wrapper"> <div class="page-title"> <h1>Not Found</h1> </div> <div class="page-content"> <p>Sorry, but you are looking for something that isn't here.</p> </div> </div> <?php endif; ?> <?php get_footer(); ?>I don’t know a lot about php though, so I can’t figure out how to fix this. Any ideas?
Cheers
The topic ‘Shortcode not working in custom page template’ is closed to new replies.