Title: Code making content disappear
Last modified: August 21, 2016

---

# Code making content disappear

 *  Resolved [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/)
 * This is my first WordPress project, so I am a little lost.
 * I have installed and activated the plugin. I have added the code `<?php echo 
   $related->show(get_the_ID()); ?>` to the template. I have selected an item to
   be “related”. When I view the post, everything below the inserted code no longer
   displays. I am sure I am making a rookie mistake. Any assistance is appreciated.
 * [http://wordpress.org/plugins/related/](http://wordpress.org/plugins/related/)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Thread Starter [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430510)
 * Also, the related item is not showing.
 *  Plugin Author [Marcel Pol](https://wordpress.org/support/users/mpol/)
 * (@mpol)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430649)
 * I will look into it.
 * Can you tell me more? Is there an error in error_log of Apache?
    Anything in 
   the html when you view the source? Also, what theme do you use?
 *  Thread Starter [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430765)
 * In View Source, nothing shows below where the code should be. You can view the
   source [here](http://rc.allinclusiveforless.com/wordpress/?dir-item=viking-europe-rhine-basel-amsterdam-2015).
   the code is placed just under the closing `</article>` tag. I have also tried
   placing it in other areas. Anywhere I place it, everything below the code disappears.
   Am I supposed to wrap the code with anything else?
 * Also, assuming I can get this up and running, it is possible to have 2 instances
   on the same post/page? I would like one section to have related ships and another
   for optional extended vacations. I know I would have to manually select the related
   content for each, I would just like to separate the related content for a cleaner
   look.
 * thanks for the prompt response. The true sign of a great developer.
 *  Plugin Author [Marcel Pol](https://wordpress.org/support/users/mpol/)
 * (@mpol)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430783)
 * Thank you. You didn’t answer all my questions though.
    – Is there anything in
   error_log of Apache? Also, – What version of PHP do you use?
 * I’m not sure what the cause is, but does it work when you place <?php global 
   $related; ?> in front of the other line?
 * I don’t see anything strange in my test environment. That is Debian Linux with
   PHP 5.5. I will test on RH5 with PHP 5.4 again.
 *  Plugin Author [Marcel Pol](https://wordpress.org/support/users/mpol/)
 * (@mpol)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430785)
 * And oh, you can have as many lists of related posts as you want I reckon. I haven’t
   tried that, but it should just work.
    The PHP instance is just an object. The
   show method returns the list, depending on the post ID that’s given as an argument.
 *  Thread Starter [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430799)
 * Sorry, nothing related in the error log. PHP version is 5.4.22
 *  Thread Starter [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430800)
 * Just added `<?php global $related; ?>` and it worked. I can now see the title
   of the related article and the rest of the content!
 *  Thread Starter [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430801)
 * Resolved. Excellent Support!
 *  Plugin Author [Marcel Pol](https://wordpress.org/support/users/mpol/)
 * (@mpol)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430836)
 * Now if I only knew why it happns with you, but not on my install :).
    I will 
   add it to the documentation at least. I will also test on another server as well.
 *  Thread Starter [enickdavis](https://wordpress.org/support/users/enickdavis/)
 * (@enickdavis)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430854)
 * Not sure why it happens on mine. I am using a template with a specific post type,
   so it may be playing tricks on it. thanks for the quick responses.
 * Also, I have worked the multiple instances of the related plugin. My WordPress
   and PHP skills are on the amateur side, so I probably took the long way to get
   a solution. Here’s what I did…
 * I unzipped your plugin and simply searched and replaced all variations of $related,
   $rel and $r (i think that was everything) with a new variation such as $ship,
   $shp and $s. I also renamed the files that contained “related” in the name. I
   zipped them up and installed through WordPress. I created 2 extra versions, so
   I have 3 running on my site.
 * I inserted the appropriate code containing the new $ship, $shp and $s on the 
   template and it worked.
 * Here is is in action: [http://rc.allinclusiveforless.com/wordpress/?dir-item=viking-europe-rhine-basel-amsterdam-2015](http://rc.allinclusiveforless.com/wordpress/?dir-item=viking-europe-rhine-basel-amsterdam-2015)
 *  Plugin Author [Marcel Pol](https://wordpress.org/support/users/mpol/)
 * (@mpol)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430861)
 * Ah, an interesting use of the plugin.
    If all those posts have no way to distinguish
   them, then your approach might be good. But I can imagine that the different 
   posts have some way to distinguish them. Like a different post_type or category.
   Then you could have 1 plugin, and have 3 more extensive loops where you do a 
   check on post_type or category, and only display those posts at that place.
 * A loop could look like:
 *     ```
       <?php
            global $related;
           $rel = $related->show(get_the_ID(), true);
   
           // Display the title of each related post
           foreach ($rel as $r) :
               if ($r->post_type == 'post') {
                      echo $r->post_title . '<br />';
               }
           endforeach;
       ?>
       ```
   

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Code making content disappear’ is closed to new replies.

 * ![](https://ps.w.org/related/assets/icon-256x256.png?rev=2313348)
 * [Manual Related Posts](https://wordpress.org/plugins/related/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/related/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/related/)
 * [Active Topics](https://wordpress.org/support/plugin/related/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/related/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/related/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [Marcel Pol](https://wordpress.org/support/users/mpol/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/code-making-content-disappear/#post-4430861)
 * Status: resolved