0

i build a onepage wordpress theme , and for showing all my pages in one page i use a loop , but shortcodes don't work (Ex : contact form 7 : the form is showing but don't work at all) this is my code :

            <?php
            /*
              Template Name: Pulse one page
             */
            $this_page = $post->ID;
            get_header();
            ?>

            <div class="hs-content-scroller">
                <!-- Header -->
                <div id="header_container">
                    <div id="header">
                        <div><a class="home"><i class="fa fa-home"></i></a>
                        </div>
                        <div><a href="" class="previous-page arrow"><i class="fa fa-angle-left"></i></a>
                        </div>
                        <div><a href="" class="next-page arrow"><i class="fa fa-angle-right"></i></a>
                        </div>
                        <!-- News scroll -->
                        <?php
                        $news_items = ot_get_option('header_news', array());
                        if (!empty($news_items)) {
                            ?>
                            <div class="news-scroll">
                                <span><i class="fa fa-line-chart"></i>RECENT ACTIVITY : </span>
                                <ul id="marquee" class="marquee">
                                    <?php
                                    foreach ($news_items as $news_item) {

                                        echo '<li><strong>' . $news_item['title'] . '</strong>' . $news_item['header_news_content'] . '</li>';
                                    }
                                    ?>


                                </ul>
                            </div>
                        <?php } ?>
                        <!-- End News scroll -->
                    </div>
                </div>
                <!-- End Header -->
                <!-- hs-content-wrapper -->
                <div class="hs-content-wrapper">
                    <?php
                    $args = array('order' => 'ASC',
                        'orderby' => 'menu_order',
                        'post_type' => 'page',
                        'post__not_in' => array($this_page),
                        'posts_per_page' => -1,
                    );
                    $the_query = new WP_Query($args);

            // The Loop
                    if ($the_query->have_posts()) :

                        while ($the_query->have_posts()) : $the_query->the_post();
                            $the_sub_query = new WP_Query(array('page_id' => $the_query->post->ID));
                            if ($the_sub_query->is_posts_page) {
                                continue;
                            }
                            $mytemplate = get_post_meta($the_query->post->ID, '_wp_page_template', true);
                            $title = $the_query->post->post_title;
                            echo "<article class='hs-content' id='section" . $the_query->post->menu_order . "'>";
                            echo "<span class='sec-icon fa " . get_post_meta($the_query->post->ID, 'iconfont-select', true) . "'></span>";
                            echo "<div class='hs-inner'>";
                            echo "<span class='before-title'>.0" . $the_query->post->menu_order . "</span>";
                            echo "<h2>$title</h2>";
                            if ($mytemplate != null) {
                                the_content();
                                get_template_part(substr($mytemplate, 0, -4));
                            } else {
                                the_content();
                            }
                            echo "</div>";
                            echo "</article>";

                        endwhile;
                    endif;

            // Reset Post Data
                    wp_reset_postdata();
                    ?>
                </div>
                <!-- End hs-content-wrapper -->
            </div>
            <!-- End hs-content-scroller -->
            <?php get_footer(); ?>
  • does your template call wp_head and wp_footer to output the necessary styles and scripts? – Milo Jul 28 '15 at 3:17
  • Yes , all works fine except shortcodes – geeky87 Jul 28 '15 at 3:19
  • @geeky87 i have put your code into index.php of Twenty_Fifteen theme, it working fine there, so you have problem with your theme – Hitesh Siddhapura Jul 28 '15 at 3:53
  • @HiteshSiddhapura : haev you testing the contact form 7 shortcode ? – geeky87 Jul 28 '15 at 3:56
  • yes i have test contact form 7 shortcode @geeky87 – Hitesh Siddhapura Jul 28 '15 at 3:58
-1

Replace all your the_content(); with echo do_shortcode(get_the_content());

  • Please explain your logic behind this – Pieter Goosen Jul 28 '15 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.