1

Just inherited a client site that is a bit of a mess and am looking for some help.

All of the content is within the php page template, it is not directed to the WYSIWYG editor at all (which I would like it to be for client sake). The first half of the content is just text, while the secone half is a query. The content in the query is fine, obviously, but I would like the top halfe (the text) to be in the editor versus the page template. Both parts are within the same loop, so maybe there needs to be two loops on the page?

I have tried to do a custom field to call to the page instead, but nothing is working. What can I do here? I'll bold the areas in question. I know it's elementary, but help!

Here is the code:

<?php
/*
Template Name: About Page
*/

$title = get_post_meta( get_the_ID(), '_msk_subtitle', true );

if ( ! trim( $title ) ) {
    $title = get_the_title();
}

$thumb_id        = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src( $thumb_id, 'full' );
$thumb_url       = $thumb_url_array[0];

get_header(); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">

            <?php while ( have_posts() ) : the_post(); ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

                    <div class="page-header" <?php echo( $thumb_url ? 'style="background-image: url(' . $thumb_url . ');"' : "" ); ?>>
                        <h1 class="page-title"><?php echo $title; ?></h1>
                    </div>

                    <div class="indent">

                        <p>**I WANT THIS INFO TO BE IN THE WYSIWYG EDITOR**</p>

                    </div>

                    <!-- indent -->


                    <!-- entry-content -->

                    <!-- quote -->

                    <h2 class="our-team-title">**Our team**</h2>

                    <div class="team-grid">

                        <?php

                        $args = array(
                            'post_type'      => 'team_member',
                            'posts_per_page' => 99,
                            'orderby'        => 'menu_order',
                            'order'          => 'ASC',
                        );

                        $team_query = new WP_Query( $args );

                        $i = 0;
                        // The Loop
                        if ( $team_query->have_posts() ) {

                            while ( $team_query->have_posts() ) {
                                $team_query->the_post();

                                $i ++;

                                if ( $i == 1 || $i == 4 || $i == 7 ) {
                                    echo '<div class="team-row">';
                                }

                                $names      = explode( ' ', get_the_title() );
                                $first_name = $names[0];

                                if ( ! $first_name ) {
                                    $first_name = get_the_title();
                                }

                                ?>

                                <div class="team-member">
                                    <p class="team-image"><?php the_post_thumbnail(); ?></p>

                                    <h3 id="<?php echo $first_name; ?>"><?php the_title(); ?></h3>
                                    <?php the_content(); ?>
                                </div>

                                <?php

                                if ( $i == 3 || $i == 6 || $i == 9 ) {
                                    echo '</div> <!-- team-row -->';
                                }

                            }

                        } else {
                            // no posts found
                        }
                        /* Restore original Post Data */
                        wp_reset_postdata();

                        ?>

                    </div> <!-- team-grid -->


                    <?php // the_content(); ?>


                </article><!-- #post-## -->

            <?php endwhile; // end of the loop. ?>

        </main><!-- #main -->
    </div><!-- #primary -->

<?php get_footer(); ?>
  • Could you please clarify your question? What is it that is not working? How do you want it to work, and how is it working now? – WebElaine Sep 25 '17 at 20:32
0

You are in luck. WordPress core includes a function to retrieve the CMS editor content and place it where you'd like it in your template. In fact, it is already in place in your template, just commented out:

the_content() is what you are looking for, but it doesn't belong where it sits in the code you posted.

<?php // the_content(); ?> <-- delete this commented out PHP.

Keeping the template you have assigned to that page, simply replace your: <p>**I WANT THIS INFO TO BE IN THE WYSIWYG EDITOR**</p> placeholder with the WP function:

<?php the_content(); ?>

Whatever is added to the CMS editor for that page will be inserted into the template at that location.

| improve this answer | |
  • THANK YOU! THANK YOU! THANK YOU! I had tried that earlier but didn't realize that the query content still pulled in at the bottom half of the page as the css was a bit junked up. I really appreciate your help. Sorry for all of the grammatical errors in the question - was in a meeting at the same time. – ingcol Sep 25 '17 at 21:17
  • 1
    I'm the worst. Where do you accept the answer? – ingcol Oct 2 '17 at 3:48
  • No worries - I'm sure you are not that bad. You should see a checkmark near the up/downvote arrows. More info: meta.stackexchange.com/a/23139 – jdm2112 Oct 3 '17 at 19:06

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.