最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

hooks - Show Post Types customized in Template Page

programmeradmin1浏览0评论

My plugin has custom Post Types that open on a custom page triggered by the following hook:

add_filter ('template_include', 'taxonomy_template'); // PRINTING PAGE

however, this page only appears when I access the menu:

Settings > Permanent Links

and saved without even changing anything, is there a hook that makes this check and saves automatically?

My plugin has custom Post Types that open on a custom page triggered by the following hook:

add_filter ('template_include', 'taxonomy_template'); // PRINTING PAGE

however, this page only appears when I access the menu:

Settings > Permanent Links

and saved without even changing anything, is there a hook that makes this check and saves automatically?

Share Improve this question asked Nov 5, 2020 at 18:17 Alisson CustodioAlisson Custodio 12 bronze badges 5
  • Filters generally don't print anything, they return. See template_include examples – Howdy_McGee Commented Nov 5, 2020 at 18:22
  • Yes, it returns correctly, but only without this change in the permanent links the page is not recognized – Alisson Custodio Commented Nov 5, 2020 at 18:29
  • Can you please explain your problem better? What are you trying to achieve, what exactly doesn't work? – fuxia Commented Nov 6, 2020 at 11:52
  • I have a template page to display data to be printed, this page for some reason did not appear without updating the wordpress settings manually, I researched and discovered that it has to do with the rewrite rules, I used flush_rewrite_rules (); and it worked – Alisson Custodio Commented Nov 8, 2020 at 3:14
  • Expensive flush_rewrite_rules() does what you are asking for. But it's unclear what do you want to check. – Max Yudin Commented Nov 13, 2020 at 13:43
Add a comment  | 

1 Answer 1

Reset to default 0

The solution found was to update the rewrite rules right after registering my new post type, using this code at the end of the function:

flush_rewrite_rules();
发布评论

评论列表(0)

  1. 暂无评论