activating custom post type handling breaks list
-
I have a commercial plugin that creates a custom post type
xyz_joband fetches items from an external server to match that cpt. I list those items on a page that queries said cpt, and I can click any item to go to its individual page that is generated fromsingle-xyz_job.php.The problems is I can’t implement Polylang’s cpt handling. When I tick the box for the cpt in the Polylang settings, this leads to my list of items becoming empty, the query that worked before now fails. I have re-saved permalinks but with no effect.
The commercial plugin creates the cpt with the ‘public’ parameter set to
false, but if I temporarily sets it to true, the box appears and I can tick it.If I keep it set to
false(which is recommended), I try using the Polylang filter infunctions.phpas per below. However, this also makes the list disappear.I’d be very grateful for assistance.
add_filter( 'pll_get_post_types', 'add_cpt_to_pll', 10, 2 );
function add_cpt_to_pll( $post_types, $is_settings ) {
if ( $is_settings ) {
// hides 'xyz_job' from the list of custom post types in Polylang settings
unset( $post_types['xyz_job'] );
} else {
// enables language and translation management for 'xyz_job'
$post_types['xyz_job'] = 'xyz_job';
}
return $post_types;
}The page I need help with: [log in to see the link]
The topic ‘activating custom post type handling breaks list’ is closed to new replies.