douao8204 2014-10-20 08:19
浏览 47
已采纳

如何在Wordpress中更改<! - more - >行为

When I click "read more" at the bottom of one of my website posts, it just loads the rest of the text in the same page and the same section, thus overflowing elements with text and spoiling my layout. I noticed there is a <!--more--> tag at the end of every Wordpress post when Read More is added from the toolbar. How can I override default behavior of this tag so that a new page is opened when a user clicks "Read More..." for a post? Update:
Post content is loaded from a php file named tazeha.php using jQuery code.
tazeha.php

<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <?php 
    require('wp-config.php');
    ?>
</head>
<body>




<?php
            $cat_id=get_cat_ID('تازه ها');
                $posts = get_posts ("cat=$cat_id&posts_per_page=1");
                if ($posts) 
            {
            foreach ($posts as $post):
                setup_postdata($post); ?>
                <h2><?php the_title(); ?></h2>
                <?php the_content();?>
                <?php endforeach;
            }
?>


</body>
</html>

Can I change the code above so that the text after a post's "" tag opens up in a new browser page (tab)?

  • 写回答

1条回答 默认 最新

  • dongmaopan5738 2014-10-22 04:59
    关注

    Following a Stackoverflow post, I added a single.php into my theme folder with the code below worked perfect i.e. my full post content is displayed in a new page when I click "read more..." link for any of my posts.
    single.php

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">         
        <?php while ( have_posts() ) : the_post(); ?>
        <h3><?php the_category('&nbsp;&rsaquo;&nbsp;'); echo "&nbsp;&rsaquo;&nbsp;"; the_title(); ?></h3>
        <?php the_content(); ?>
        <?php endwhile; // end of the loop. ?>
        </div><!-- #content -->
    </div><!-- #primary -->
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示