【问题标题】:Page title and content in wrong order (wordpress/bootstrap/php)页面标题和内容顺序错误(wordpress/bootstrap/php)
【发布时间】:2017-11-22 21:59:56
【问题描述】:

我的 Wordpress 4.7.8 localhost 自定义主题网页出现问题。 尽我所能,我一直在内容应该在的地方得到“标题”,在标题的地方得到内容 Here is an image 这是它在 wordpress 管理仪表板中的外观: ...and image the view in wordpress

我可能会出错的任何想法?

【问题讨论】:

    标签: wordpress content-management-system webpage


    【解决方案1】:

    试试这个代码。

    Search bar in duplicate (wordpress/php/bootstrap)

    这段代码取自您之前的问题。

    此代码用于显示标题<?php the_title(); ?>,此代码用于显示内容<?php the_content(); ?>。您可以在任何地方替换此代码。

        <?php get_header(); ?>
    
        <div class="row">
    
            <div class="col-xs-12 col-sm-8">
    
                <div class="row text-center no-margin">
    
                <?php 
                $currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
                $args = array('posts_per_page' => 3,'post_type'=>'post', 'paged' => $currentPage);
                new WP_Query($args);
                if( have_posts() ): $i = 0;
    
                    while( have_posts() ): the_post(); ?>
    
                        <?php 
                            if($i==0): $column = 12; $class = '';
                            elseif($i > 0 && $i <= 2): $column = 6; $class = ' second-row-padding';
                            elseif($i > 2): $column = 4; $class = ' third-row-padding';
                            endif;
    
                        ?>
    
    
                            <div class="col-xs-<?php echo $column; echo $class; ?> blog-item">
                                <?php if( has_post_thumbnail() ):
                                    $urlImg = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
                                endif; ?>
                                <div class="blog-element" style="background-image: url(<?php echo $urlImg; ?>);">
    
                                    <!--<?php the_title( sprintf('<h1 class="entry-title"><a href="%s">', esc_url( get_permalink() ) ),'</a></h1>' ); ?> -->
                                     <h1 class="entry-title"><?php the_title(); ?></h1>
    
                                     <?php the_content(); ?>
    
                                    <small><?php the_category(' '); ?></small>
                                </div>
                            </div>
    
                    <?php $i++; endwhile; ?>
    
                    <div class="col-xs-6 text-left">
                        <?php next_posts_link('« Older Posts'); ?>
                    </div>
                    <div class="col-xs-6 text-right">
                        <?php previous_posts_link('Newer Posts »'); ?>
                    </div>
    
                <?php endif;
                        wp_reset_query();
                ?>
                </div>
    
            </div>
    
            <div class="col-xs-12 col-sm-4">
                <?php get_sidebar(); ?>
            </div>
    
        </div>
    

    【讨论】:

    • 非常感谢!这解决了标题和页面内容顺序错误的问题。现在我只需要解决我的双发问题:)
    • 很高兴帮助你.. :)
    【解决方案2】:

    您可能需要编辑 content-single.php 文件来更改发布内容的顺序。您的帖子内容在帖子标题之前首先加载。

    检查是否,

    the_content() or get_the_content()
    

    之前显示过,

    get_the_title() or the_title()
    

    【讨论】:

      猜你喜欢
      • 2019-08-30
      • 2018-10-12
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-28
      • 2022-08-17
      相关资源
      最近更新 更多