Replace Content of Sidebar on Custom Post Type

After a lot of trying and testing, I think I’ve found a solution: add_filter( ‘sidebars_widgets’, ‘exchange_sidebars’, 10); function exchange_sidebars( $sidebars_widgets ){ global $post; // Define the sidebar which should be exchanged $selected_sidebar=”sidebar-1″ // IF we are on a custom post type // AND it is a Child Page (= page has post_parent) // THEN change … Read more

How to create additional rendering for custom post types?

You need to use add_rewrite_tag and add_rewrite_rule functions to first register your custom URL handlers. Something like add_rewrite_tag( ‘%custom_render%’, ‘true’ ); add_rewrite_rule( ‘([^/]+)/custom_render/?$’, ‘index.php?name=$matches[1]&custom_render=true’, ‘top’ ); And then you can us template_inclide hook to check if the query param custom_render is set, then return the name of the new template. Note: You need to flush … Read more

Filter custom post type admin list by custom meta column, where the column is another custom posts meta value

One solution may be to get all position ids, where project id matches and compare them with the ‘OR’ comparer. $position_ids = get_positions_in_project($project_id); foreach ($position_ids as $id) { $meta_query[] = array( ‘key’ => ‘feedback_position_relation’, ‘value’ => $id, ‘compare’ => ‘=’, ); } $meta_query[‘relation’] = ‘OR’; $query->set(‘meta_query’, $meta_query) But the problem with this is, that meta … Read more