I'm trying to echo the content of a single post by using the_content(); but I get an empty result. However when I directly address the global $post, and specifically the post_content property it does show. What can cause such peculiar behaviour?

CODE: the problematic line is near the end

get_header(); ?>
<div id="com_page" class="content">
    <ul id="com_list">
        $title = get_the_title();
        $q = new WP_Query(array(
        if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); ?>
         <li><a href="<?php the_permalink(); ?>" <?php if ($title==get_the_title()) echo "class=com_sel"; ?> ><?php the_title(); ?></a></li>
        <?php endwhile; ?>
             <?php endif; ?>
    <div id="com_content">
         <div id="title">
             <h1>קהילות צעירות<span> <?php wp_reset_query(); the_post(); the_title(); ?><span></h1>
             $forum_id =  $wpdb->get_row("SELECT id FROM wp_forum_forums WHERE name='$title'"); // find forum id

         <ul id="com_menu" class=clearfix>
            <li><a href="<?php the_permalink(); ?>" <?php if (!isset($_GET['tab'])) {echo "class=com_sel"; $page = "אודות הקבוצה";} ?>>אודות הקבוצה</a></li>
            <li><a href="<?php the_permalink(); ?>/?tab=events" <?php if (isset($_GET['tab']) && $_GET['tab']=='events') {echo "class=com_sel"; $page = "ארועים";} ?>>ארועים</a></li>
            <li><a href="<?php the_permalink(); ?>/?tab=gallery" <?php if (isset($_GET['tab']) && $_GET['tab']=='gallery') {echo "class=com_sel"; $page = "גלריה";} ?>>גלריה</a></li>
            <li><a href="http://localhost/midor/%D7%A4%D7%95%D7%A8%D7%95%D7%9D/?mingleforumaction=viewforum&f=<?php echo $forum_id->id;  ?>.0">פורום</a></li>
        <h1><?php echo $page; ?></h1>
        <?php if (isset($_GET['tab']) && $_GET['tab']=='events'): ?>
        <!-- Events code -->
        <?php elseif (isset($_GET['tab']) && $_GET['tab']=='gallery'):  ?>
        <!-- Gallery code -->
        <?php else: ?>
        <!-- About code -->
         <div id="about_imgs">
             <img src="" alt="">
         <div id="about_txt" style="background:red !important;">
           <?php  the_content(); ?>   // not working
           <div class="clear"></div>    
        <?php endif; ?> 


  • Just to test, could you try running the Page without the <ul> and the custom loop on top? Please tell me if the Error still exists in this case.
    – fischi
    Dec 28, 2012 at 9:44
  • And also, are you sure your conditional at the end (with Events, Gallery and About) gets you to the 'About code'?
    – fischi
    Dec 28, 2012 at 9:45
  • you are right, it is the cause. When I remove the UL the content does show. Any idea why?
    – Matanya
    Dec 28, 2012 at 9:47
  • actually, the UL causing the problem is the #com_menu one, not the #com_list
    – Matanya
    Dec 28, 2012 at 9:50
  • Yes, I'm sure it gets me to the about code
    – Matanya
    Dec 28, 2012 at 9:51

1 Answer 1


After the <ul> part you do reset the query, but you also have to reset the original postdata:


and in the line

<a href="<?php the_permalink(); ?>" <?php if (!isset($_GET['tab'])) {echo "class=com_sel"; $page = "אודות הקבוצה";} ?>>אודות הקבוצה

the php and if tags are mixed up, i don't know if PHP understands it like that.

should be like this:

<a href="<?php the_permalink(); ?>" <?php if (!isset($_GET['tab'])) {echo "class=com_sel"; $page = "אודות הקבוצה";} ?>
        אודות הקבוצה

I think this is a mixup with rtl and ltr direction of the language.

  • correct! will accept in 2 mins
    – Matanya
    Dec 28, 2012 at 9:55
  • cool. just out of curiosity - does PHP understand the Tags when they are written in RTL direction?
    – fischi
    Dec 28, 2012 at 9:58
  • the tags themselves are in english, aren't they?
    – Matanya
    Dec 28, 2012 at 10:00
  • as for the apparent syntax error it is fine on my end, just wasn't parsed well when I pasted it, due to directionality issues
    – Matanya
    Dec 28, 2012 at 10:03
  • yeah they are, but when I look at the code you posted, they are in the opposite direction for me. strange thing, never noticed this before, but sure is correct - when i copy past your version in this window, the direction is written LTR ;) so nevermind :)
    – fischi
    Dec 28, 2012 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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