单击帖子链接导致PHP WordPress中的空白页

发布于 2025-02-09 19:14:31 字数 842 浏览 1 评论 0原文

我一直在尝试学习PHP,并且我被困在某一时刻。我创建了一些帖子并将其作为链接,但是在单击它们时,它们将我带到了空白页。

这是index.php code

      <?php 
     while(have_posts()){
        the_post();?>
        <h2><a href="get_the_permalink()"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
    <?php
     }
    ?>

这是single.php代码

    <?php 
     while(have_posts()){
        the_post();?>
        <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
    <?php
     }
    ?>

我将href值更改为另一个工作链接,它的工作很漂亮好吧,可能是永久链接的问题。我去了WordPress dashboard- permalink,尝试了各种常见设置,但是问题仍然存在,有人可以帮助我吗?

I have been trying to learn PHP, and I am stuck at one point. I created some posts and made them as links, but on clicking them, they lead me to a blank page.

Here is the index.php code

      <?php 
     while(have_posts()){
        the_post();?>
        <h2><a href="get_the_permalink()"><?php the_title(); ?></a></h2>
        <?php the_content(); ?>
    <?php
     }
    ?>

Here is the single.php code

    <?php 
     while(have_posts()){
        the_post();?>
        <h2><?php the_title(); ?></h2>
        <?php the_content(); ?>
    <?php
     }
    ?>

I changed the href value to another working link, and it was working pretty well, the problem maybe with permalink. I went to WordPress dashboard->permalink and tried all kinds of common settings, but the problem still exists, could someone help me out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜巴黎 2025-02-16 19:14:31

您必须使用php函数始终包裹在&lt;?php - ?&gt;

<?php 
 while(have_posts()){
    the_post();?>
    <h2><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
<?php
 }
?>

You have to use PHP functions always wrapped inside <?php - ?>

<?php 
 while(have_posts()){
    the_post();?>
    <h2><a href="<?php get_the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content(); ?>
<?php
 }
?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文