Last active
October 18, 2023 03:34
-
-
Save wpt00ls/4c0e6f448f1458ff7937b2684d16df03 to your computer and use it in GitHub Desktop.
Modify the faq post type and taxonomy args to make them public and searchable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add this code to your child theme's function.php | |
| // Filter to modify default post type args | |
| add_filter('register_post_type_args', 'modify_faq_post_type_args', 10, 2); | |
| /** | |
| * Modify FAQ post type args to make them public and searchable | |
| */ | |
| function modify_faq_post_type_args( | |
| $args, | |
| $post_type | |
| ) { | |
| if ($post_type == 'wpt-faq') { | |
| $args['public'] = true; | |
| $args['exclude_from_search'] = false; | |
| $args['publicly_queryable'] = true; | |
| } | |
| return $args; | |
| } | |
| // Making FAQ taxonomy public. | |
| add_filter('register_taxonomy_args', 'modify_faq_taxonomy_args', 10, 3); | |
| // Modify FAQ taxonomy to make it public | |
| function modify_faq_taxonomy_args( | |
| $args, | |
| $taxonomy, | |
| $object_type | |
| ) { | |
| if ($taxonomy == 'wpt-faq-cat') { | |
| $args['public'] = true; | |
| $args['publicly_queryable'] = true; | |
| } | |
| return $args; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment