Title: Wrong display in a post
Last modified: August 21, 2016

---

# Wrong display in a post

 *  Resolved [chazalthibault](https://wordpress.org/support/users/chazalthibault/)
 * (@chazalthibault)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/wrong-display-in-a-post/)
 * Hi
    I’ve found in this post [showing-one-pages-content-on-another-page](http://wordpress.org/support/topic/showing-one-pages-content-on-another-page?replies=22)
   a shortcode which work very well (thanks gabrielcastillo)
 * >  you can wrap this into a shortcode as well. Paste this in your functions.php
   > file and you can now use the shortcode
   >  ” [my_content id=”Enter your page id
   > number” title=Set this to true if you want to show title /] “
   >     ```
   >     function get_post_page_content( $atts ) {
   >     			extract( shortcode_atts( array(
   >     				'id' => null,
   >     				'title' => false,
   >     			), $atts ) );
   > 
   >     			$the_query = new WP_Query( 'page_id='.$id );
   >     			while ( $the_query->have_posts() ) {
   >     				$the_query->the_post();
   >     			        if($title == true){
   >     			        the_title();
   >     			        }
   >     			        the_content();
   >     			}
   >     			wp_reset_postdata();
   > 
   >     		}
   >     		add_shortcode( 'my_content', 'get_post_page_content' );
   >     ```
   > 
 * But I would like to use it in an other shortcode, a tab (I have 3 tab).
 * My code look like this :
 *     ```
       [tabgroup]
   
       [tab title="Forum"][my_content id="2149" title="" /][button size=medium style=less_round color=blue align=right url=http://zangomedia.fr/forum]Accéder au Forum[/button][/tab]
       [tab title="Mes copains"][my_content id="2145" title=""/][button size=medium style=less_round color=blue align=right url=http://zangomedia.fr/friends]Aller voir les copains[/button][/tab]
   
       [tab title="Mon Profil"][my_content id="2142" title="" /][button size=medium style=less_round color=blue align=right url=http://zangomedia.fr/profil]Voir mon profil[/button][/tab]
   
       [/tabgroup]
       ```
   
 * The problem is that the post are displays first and outside the tabs…
    Here is
   the result [http://zangomedia.fr/salle-commune/](http://zangomedia.fr/salle-commune/)
 * If you have any idea to correct it, I would be glad!
 * Thanks and have fun!
    Thibault

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/wrong-display-in-a-post/#post-5134601)
 * your shortcode does ‘_echo_‘ the reulsts – to work properly as shortcode, it 
   should ‘_return_‘ the results.
 * example:
 *     ```
       function get_post_page_content( $atts ) {
       			extract( shortcode_atts( array(
       				'id' => null,
       				'title' => false,
       			), $atts ) );
   
       			$the_query = new WP_Query( 'page_id='.$id );
       			$output = '';
       			while ( $the_query->have_posts() ) {
       				$the_query->the_post();
       			        if($title == true){
       			        $output .= get_the_title();
       			        }
       			        $output .= apply_filters( 'the_content'), get_the_content() );
       			}
       			wp_reset_postdata();
       			return $output;
       		}
       		add_shortcode( 'my_content', 'get_post_page_content' );
       ```
   
 * not tested.
 *  Thread Starter [chazalthibault](https://wordpress.org/support/users/chazalthibault/)
 * (@chazalthibault)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/wrong-display-in-a-post/#post-5134616)
 * Okay I see
    I don’t know why yet but your code put my whole site down… I don’t
   see where is the mistake… I’m not that good in php!
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/wrong-display-in-a-post/#post-5134619)
 * I had a typo in the code:
    excess bracket in this line:
 *     ```
       $output .= apply_filters( 'the_content'), get_the_content() );
       ```
   
 * – corrected line:
 *     ```
       $output .= apply_filters( 'the_content', get_the_content() );
       ```
   
 *  Thread Starter [chazalthibault](https://wordpress.org/support/users/chazalthibault/)
 * (@chazalthibault)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/wrong-display-in-a-post/#post-5134620)
 * Perfectly working
    Thank you so much!!!

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

The topic ‘Wrong display in a post’ is closed to new replies.

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [chazalthibault](https://wordpress.org/support/users/chazalthibault/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/wrong-display-in-a-post/#post-5134620)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
