0

I am having trouble trying to pull then content from the page's WYSIWYG editor.

The template index.php file is set up like nothing I have seen before and I am simply trying to sort this out. I have tried using the loop method (which should always be used) i have tried another method by defining the content function in the index.php and nothing seems to work. The closest I get is pulling the most recent post on to the page rather than the WYSIWYG content.

This is the other attempt with the Loop put in. This relays no content from the WYSIWYG editor on to the page:

   <?php 
get_header(); 

$homeId = 187;
$roomImg = get_field("front_room_image", $homeId); 
$middleImg = get_field("middle_image", $homeId);
$cornerImg = get_field("right_bottom_corner", $homeId);
$ipadcornerImg = get_field("right_bottom_corner_ipad", $homeId);
$image_url = wp_get_attachment_image_src($middleImg['id'], 'front-middle-image');
$roomSrc = wp_get_attachment_image_src($roomImg['id'], 'floor-image');
$cornerImgSrc = wp_get_attachment_image_src($cornerImg['id'], 'right-bottom-corner');
$cornerImgSrcIpad = wp_get_attachment_image_src($ipadcornerImg['id'], 'right-bottom-corner-ipad');
$rightCornerImg = ((wp_is_mobile()) ? $cornerImgSrcIpad[0] : $cornerImgSrc[0]);
$email = get_post_meta($homeId, "insert_email", true);
$skype = get_post_meta($homeId, "skype_user_name", true);
$slider = array('post_type' => 'wpt_slider', 'posts_per_page' => 4, 'posts_status' => 'publish');
$posts = get_posts($slider);
$req = new wp_query($slider);
$menuLabel = get_field("menu_blog", $homeId);
$middle_image_laptop = get_field("middle_image_laptop", $homeId);
$midId = $middle_image_laptop['id'];
$front_room_image_laptop = get_field("front_room_image_laptop", $homeId);
$friID = $front_room_image_laptop['id'];

$mid_img = wp_get_attachment_image_src($midId, 'middle_image_laptop');
$fri_img = wp_get_attachment_image_src($friID, 'front_room_image_laptop');
    $content = get_the_content( $more_link_text, $strip_teaser );

    /**
     * Filters the post content.
     *
     * @since 0.71
     *
     * @param string $content Content of the current post.
     */
    $content = apply_filters( 'the_content', $content );
    $content = str_replace( ']]>', ']]&gt;', $content );

?>
<script>
    $(document).ready(function(e) {
      /*//Super Slides
      $('.slides').superslides({
        inherit_width_from: '.wide-container',
        inherit_height_from: '.wide-container',
         animation: 'slide',
        play:6000
      });*/

      //Super Slides
          $('.slides').superslides({
            inherit_width_from: '.wide-container',
            inherit_height_from: '.wide-container',
             animation: 'slide',
            play:6000
          });
        //Super Slides
          $('.slides1').superslides({
            inherit_width_from: '.wide-container1',
            inherit_height_from: '.wide-container1',
             animation: 'slide',
            play:false
          });
        //Super Slides
          $('.slides2').superslides({
            inherit_width_from: '.wide-container2',
            inherit_height_from: '.wide-container2',
             animation: 'slide',
            play:false
          });
        //Super Slides
          $('.slides3').superslides({
            inherit_width_from: '.wide-container3',
            inherit_height_from: '.wide-container3',
             animation: 'slide',
            play:false
          });
        //Super Slides
          $('.slides4').superslides({
            inherit_width_from: '.wide-container4',
            inherit_height_from: '.wide-container4',
             animation: 'slide',
            play:false
          });

    });
</script>



<div id="content-area">
    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>    
  <div><p><?php the_content(); ?></p></div>
    <?php endwhile; ?>
<?php endif; ?>
  <div id="TwelveDrid">
    <section class="BgTransition">
      <div class="wide-container">
        <div class="slides">
          <div class="slides-container"> <?php echo roomSlider(); ?> </div>
        </div>
      </div>
    </section>
  • I don't fully understand the situation. Do you use the_content() and you don't get the expected result? What result do you expect and what you get instead? Note that index.php is a very generic template file, although pages can use this template, most themes have dedicated template files for single pages. – cybmeta Jan 15 '18 at 16:31
  • $posts = get_posts($slider); $req = new wp_query($slider); - this could very well interfere with the main loop - thus your main loop actually doesn't do anything. Try not using get_posts, but use only WP_Query, and after you used it, use wp_reset_query(); to return to the main loop. – D. Dan Jan 16 '18 at 7:50
  • @cybmeta Yes I am using the_content() to try and pull the content from wordpress standard WYSIWYG editor. This is not working for the root page "/" but it relays the content out to the /home/ page. The only problem is that all the previous changes made to index.php relay to the root and not '/home/'. Even when I just hard code the information straight into index.php it shows on the root but not /home/. – Liam Jan 16 '18 at 16:30
  • What is your configuration in "Settings->Reading->Your homepage displays"? I think that you incorrectly expect index.php template be used when it is not. – cybmeta Jan 16 '18 at 16:52

Your Answer

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

Browse other questions tagged or ask your own question.