【问题标题】:Wordpress-redirect homepage to index.phpWordpress 将主页重定向到 index.php
【发布时间】:2016-09-19 18:07:31
【问题描述】:

我是 Wordpress 的新手。当我去时,我的网站加载正常 mydomain.com。现在我创建了一个名为Home 的页面及其 永久链接是mydomain.com/homepage。 如果我点击 home 它不会加载帖子。

如何将Home 链接到站点的根目录(index.php)?

index.php

<?php

get_header();
?>
<h1>index.php</h1>
<?php 

    if(have_posts()):

    while(have_posts()):the_post();
?>
    <article class="post">
         <h2><a href="<?php the_permalink();?>"><?php the_title() ?></a></h2>
         <?php the_content(); ?>
     </article>

<?php       
    endwhile;
else:

    echo '<p>No content found</p>';

endif;
?>

<?php 
   get_footer();

?>

【问题讨论】:

  • 在 Settings->permalinks 中将永久链接结构更改为“帖子名称”

标签: wordpress


【解决方案1】:

试试这个。

转到设置>阅读>选择“静态页面”(单选按钮),然后在首页:(下拉菜单)中选择您的“主页”(页面)。

希望我能帮上忙。

【讨论】:

  • 我试过了。它加载 index.php,但不显示帖子。
  • 在您的主页发帖?
  • 我更新了我的帖子。它显示“未找到内容”
  • 你的主页有循环吗?
  • 不确定你的意思。如果我将静态页面设置为主页,则 parmalink 更改为 mydomain.com 并且它不会加载 index.php 中的帖子
【解决方案2】:

代码好像不对,你用的是什么主题?

无论如何,如果您更改阅读设置以显示静态页面,您可以创建一个文件并将其命名为 home.php,该文件将接管 index.php

在此处放置您想要显示为主页的任何内容

【讨论】:

    【解决方案3】:

    如果有人想知道,如何将Home 链接重定向到example.com

    很简单,

    WP后端->外观->菜单->点击自定义链接->添加标题(Home)和链接(http://example.com)->添加到菜单。

    希望它可以帮助某人:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      • 1970-01-01
      • 2017-07-09
      • 2015-05-30
      • 2013-06-08
      相关资源
      最近更新 更多