【问题标题】:Change “POST” type slug in WordPress在 WordPress 中更改“POST”类型的 slug
【发布时间】:2020-02-15 10:48:37
【问题描述】:

/wp-admin/edit.php?post_type=project

如何在 wordpress 中更改默认帖子的 slug(从项目到项目)

我尝试通过添加下面的功能

add_filter(
    'pre_post_link',
    function ($permalink, $post) {
        if ($post->post_type !== 'project') {
            return $permalink;
        }

        return '/projects';
    },
    10,
    2
);

但它不起作用

【问题讨论】:

  • 您是否使用任何插件来自定义帖子类型?
  • 不,主题是@Krupal Panchal
  • 它看起来像一个自定义帖子类型。请再检查一次。
  • 不,我非常确定这是带有主题@Krupal Panchal 的默认帖子
  • 你使用的是哪个主题?

标签: php wordpress custom-post-type


【解决方案1】:

$args['rewrite']['slug'] = 'projects';

在 if 条件中添加此代码并从 if 条件中删除 return

【讨论】:

    猜你喜欢
    • 2013-02-16
    • 2017-03-30
    • 2018-11-15
    • 2019-02-16
    • 2022-12-30
    • 1970-01-01
    • 2017-01-31
    • 1970-01-01
    • 2014-02-17
    相关资源
    最近更新 更多