the_content() isn’t showing content, but $post->post_content does

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

<?php  
get_header(); ?>
<div id="com_page" class="content">
    <ul id="com_list">
        <?php 
        $title = get_the_title();
        $q = new WP_Query(array(
            'post_type'=>'community',
            'numberposts'=>-1,
            'orderby'=>'title',
            'order'=>'asc'));
        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; ?>
    </ul>
    <div id="com_content">
         <div id="title">
             <h1>קהילות צעירות<span> <?php wp_reset_query(); the_post(); the_title(); ?><span></h1>
             <?php 
             $title=get_the_title();
             $forum_id =  $wpdb->get_row("SELECT id FROM wp_forum_forums WHERE name='$title'"); // find forum id
             ?>

             </div><!--title-->
         <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>
        </ul><!--com_menu-->
        <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>
         <div id="about_txt" style="background:red !important;">
           <?php  the_content(); ?>   // not working
           <div class="clear"></div>    
         </div>
        <?php endif; ?> 
    </div><!--com_content-->

</div><!--com_page-->
<?php

get_sidebar();
get_footer(); 

Related posts

Leave a Reply

1 comment

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

    wp_reset_postdata();
    

    and in the line

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

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

    should be like this:

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

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