Single.php不在WordPress网站上显示帖子内容

时间:2014-03-28 02:15:10

标签: php wordpress post

我安装的主题不显示帖子内容 - 除帖子标题,类别等外(http://www.laredohospitality.com/new-locations-opening/) 摘要似乎没有问题 - http://www.laredohospitality.com/category/job-posting/

当切换到TwentyTwelve,Thirteen等时,帖子显示顺利,因此我知道这个主题会让人感到不安。

我已经阅读过Themeforest的支持,但无济于事 - 至少可以说这个主题代码的许多负面批评,但除非我能改变我的客户的想法这是他们满意的主题。

我尝试了一个非常基本的single.php,虽然有效但我不能在不破坏该代码的情况下实现这个主题的侧边栏和花哨的附加功能。

这是single.php没有任何我尝试修复它 - 任何帮助将不胜感激。谢谢!

<?php get_header(); ?>
    <!-- BEGIN PAGE TITLE -->
    <div id="page-title-wrap">
        <?php 
            if (have_posts()) : while (have_posts()) : the_post(); 
            global $menuItem;
            if ( post_is_in_descendant_category( 12 ) ) {
                $menuItem=true;
            }
            else {
                $menuItem=false;
            }
        ?>
        <div id="page-title">
            <div id="page-title-content"><?php 
                    if ($menuItem) {
                        $pageId = 236;
                    }
                    else {
                        $pageId = 150;
                    }
                    $page=get_page($pageId);
                    echo $page->post_title; 
                ?>
                <img id="left-ornament" src="<?php echo get_template_directory_uri() ?>/images/left_ornament.png" alt="Left ornament" />
                <img id="right-ornament" src="<?php echo get_template_directory_uri() ?>/images/right_ornament.png" alt="Right ornament" />
            </div>
            <div id="page-title-descr"><?php echo "(".get_post_meta(150, "description", true).")"; ?></div>
        </div>
    </div>
    <!-- END PAGE TITLE -->
    <div id="main-content">
        <!-- BEGIN CONTENT -->
        <div id="content-left">
            <div class="post-wrap">
                <?php if (!$menuItem) { ?>
                <div class="post-date">
                    <span class="day"><?php the_time('d'); ?></span> 
                    <span class="month"><?php the_time('M'); ?></span> 
                    <span class="year"><?php the_time('Y'); ?></span>
                </div>
                <a href="<?php the_permalink() ?>"><div class="post-header"><?php the_title() ?></div></a>
                <div class="post-info-wrap">POST BY: <span class="author-name"><?php the_author_posts_link() ?></span> in <a href=""><?php the_category(', '); ?></a> with <?php if ( get_comments_number() != 0 ) { ?><a href="<?php echo get_permalink() . '#comment-section' ?>"><?php comments_number(); ?></a><?php } else { comments_number('0 Comments'); }?> </div>
                <?php } else { ?>
                <a href="<?php the_permalink() ?>"><div class="post-header without-date"><?php the_title() ?></div></a>
                <?php } ?>
                <div class="post-descr">
                    <?php 
                        if ( has_post_thumbnail() ) {
                            the_post_thumbnail('large');
                        } 
                        the_content(' '); 
                        endwhile; endif;

                    ?>
                </div>
                <div class="divider"></div>
            </div>
            <?php 
                comments_template(); 
                if ($menuItem) {
                    $categories = get_categories ( array( 'type' => 'post', 'child_of' => 12, 'order_by' => 'id') );
                    foreach ($categories as $category) {
                        query_posts( array( 'cat' => $category->term_id, 'post_type' => 'post') );
                        if ( have_posts() ) : while ( have_posts() ) : the_post();
                        $custom_fields = get_post_custom(); 
                        global $featuredDishes;
                        if ( $custom_fields['featured']==true ) {
                            $featuredDishes.="<img src='".get_template_directory_uri()."/images/star.png' alt='Star Icon' class='sidebar-popular-star' />";
                            $featuredDishes.="<a href='".get_permalink()."'>".the_title('','',false)."</a>";
                            $featuredDishes.="<div class='sidebar-desc'>".get_post_meta(get_the_ID(), "ingredients", true)."</div>;";
                        }
                        endwhile; endif;
                    }
                }
                else {
                    //Prepare data for "Popular Posts" section
                    query_posts( array( 'cat' => "-12,-17", 'post_type' => 'post', 'posts_per_page' => -1 ) );
                    $g=0;
                    global $popularPosts;
                    if ( have_posts() ): while ( have_posts() ) : the_post();
                    if ( get_comments_number() > 0 ) {
                        $popularPosts[$g]['value'] = '<img src="'.get_template_directory_uri(). '/images/star.png" alt="Star icon" class="sidebar-popular-star" />';
                        $popularPosts[$g]['value'].= '<a href="'.get_permalink().'" title="'.the_title('','',false).'">'.the_title('','',false).'</a> ';
                        $popularPosts[$g]['value'].= '<div class="sidebar-desc">by ' .get_the_author(). ', '.get_the_time('d M y').'</div>';
                        $popularPosts[$g]['count'] = get_comments_number();
                    }
                    $g++;
                    endwhile;endif;
                    wp_reset_query();
                    // Sort post by comments count
                    function compare_count($a, $b){
                        return strnatcmp( $b['count'], $a['count'] );
                    }
                    usort($popularPosts, 'compare_count');
                }
            ?>
        </div>
        <!-- END CONTENT -->
        <!-- BEGIN SIDEBAR -->
        <?php if (!$menuItem) { ?>
        <div id="content-right" class="addictional-contact">
            <?php get_sidebar('blog') ?>
        </div>
        <?php } else { ?>
        <div id="content-right" class="addictional-contact">
            <?php get_sidebar('menu') ?>
        </div>
        <?php } ?>
        <!-- END SIDEBAR -->
    </div>

2 个答案:

答案 0 :(得分:0)

嗯..请尝试将the_content(' ');更改为the_content();

可能在functions.php文件中添加内容的特殊过滤器,从而破坏了输出

答案 1 :(得分:0)

标题中看似无关的东西(两个装饰图像)正在影响帖子。去图。

感谢大家的帮助!我删除了下面的代码,一切正常。

    <img id="left-ornament" src="<?php echo get_template_directory_uri() ?>/images/left_ornament.png" alt="Left ornament" />
    <img id="right-ornament" src="<?php echo get_template_directory_uri() ?>/images/right_ornament.png" alt="Right ornament" />