Skip to content

Instantly share code, notes, and snippets.

@wpt00ls
Last active October 18, 2023 03:34
Show Gist options
  • Select an option

  • Save wpt00ls/4c0e6f448f1458ff7937b2684d16df03 to your computer and use it in GitHub Desktop.

Select an option

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.
<?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