admin管理员组

文章数量:1122826

I am new to php and Wordpress. I currently have custom type named "helppost" that should hold Help posts. It has three categories:

  • 'Getting Started' with slug "getting-started"
  • 'Safety and Privacy' with slug "safety-and-privacy"
  • 'Trouble Shooting' with slug "trouble-shooting"

I have an archive page that shows help posts for each of these 3 help categories. I have a hook that needs to perform a certain business logic when I am on this archive.

I am currently using Elementor Pro.

How do I know if I the user is currently looking at the archive of these help categories? I looked at many functions but nothing seemed to work.

is_post_type_archive() did not work is_archive() did return 1 but I need to know that if the archive belongs to one of the categories. I don't want the archive of a blog post for example.

Please let me know which function I should call and parameters I should pass it as i am new to Wordpress and php.

Thanks

I am new to php and Wordpress. I currently have custom type named "helppost" that should hold Help posts. It has three categories:

  • 'Getting Started' with slug "getting-started"
  • 'Safety and Privacy' with slug "safety-and-privacy"
  • 'Trouble Shooting' with slug "trouble-shooting"

I have an archive page that shows help posts for each of these 3 help categories. I have a hook that needs to perform a certain business logic when I am on this archive.

I am currently using Elementor Pro.

How do I know if I the user is currently looking at the archive of these help categories? I looked at many functions but nothing seemed to work.

is_post_type_archive() did not work is_archive() did return 1 but I need to know that if the archive belongs to one of the categories. I don't want the archive of a blog post for example.

Please let me know which function I should call and parameters I should pass it as i am new to Wordpress and php.

Thanks

Share Improve this question edited May 7, 2024 at 19:38 Aimn Blbol 1033 bronze badges asked May 7, 2024 at 3:26 AimnAimn 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You could consider using is_tax:

Determines whether the query is for an existing custom taxonomy archive page.

You can pass in the taxonomy slug to test if the current taxonomy archive page is for your taxonomy:

if ( is_tax( 'my_taxonomy' ) ) {

本文标签: pluginsHow do I know if an archive correspond to a custom post type taxonomy