简体   繁体   English

Wordpress 将单个帖子永久链接重定向到首页.php 文件

[英]Wordpress redirects single post permalink to the front-page.php file

Having a strange wordpress custom theme issue that I can't crack.有一个奇怪的 wordpress 自定义主题问题,我无法破解。

I have a custom post type 'artists' that I am displaying posts for that include a link with the_permalink();我有一个自定义帖子类型“艺术家”,我正在为其显示包含与 the_permalink() 的链接的帖子;

I expect this permalink to take me to the template that I have named single-artists.php -- but instead it takes me to front-page.php every time, even though the link in the browser is the correct permalink that should take me to the single post page.我希望这个永久链接将我带到我命名为 single-artists.php 的模板——但它每次都会将我带到 front-page.php,即使浏览器中的链接是应该带我的正确永久链接到单个帖子页面。

I have refreshed my permalinks in settings several times, and I have loaded the page and flushed my cache/removed cookies. Still going to front-page.php, no matter what post I click on, even though the permalink does change each time.我在设置中刷新了我的永久链接几次,我已经加载了页面并刷新了我的缓存/删除了 cookies。仍然会转到首页。php,无论我点击什么帖子,即使永久链接每次都会改变。

Anything else I should be doing?还有什么我应该做的吗? AFAIK the naming convention for single-artists.php is correct as the post type IS artists. AFAIK 单一艺术家的命名约定。php 是正确的,因为帖子类型是艺术家。

Classic case of me being a beginner, I hadn't noticed that my posts had been hidden from public.我是初学者的经典案例,我没有注意到我的帖子已对公众隐藏。 Setting public to true (like below) fixed it.将 public 设置为 true(如下所示)修复了它。 If there's any other newbies who run into this hopefully this helps you!如果还有遇到此问题的其他新手,希望这对您有所帮助!

function create_artist_post() {
  $args = array(
    'labels' => array(
      'name' => 'Artists',
      'singular_name' => 'Artist'
    ),
    'public' => true,
    'show_ui' => true,
    'menu-position' => 20
  );
  register_post_type('artists', $args);
}

add_action('init', 'create_artist_post');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM