Have a Custom Post Type index page display taxonomy items instead of posts

If you’d like to list the individual courses, i.e. the taxonomy terms, you’d use neither WP_Query nor the WP standard Loop. Instead, make use of the get_terms function to retrieve the courses. It returns an array of term objects (if the taxonomy does exist and has terms matching the function arguments). Iterate over that and … Read more

Custom Post Type Navigation on Custom Field

For previous and next post links to work, you need to hook on to the get_*_post_* filters and modify the query to actually sort the posts using your custom field. I hope the code below will work for you. For Previous post link add_filter(‘get_previous_post_join’, ‘wpse96670_get_previous_post_join_custom_sort’); add_filter(‘get_previous_post_where’, ‘wpse96670_get_previous_post_where_custom_sort’); add_filter(‘get_previous_post_sort’, ‘wpse96670_get_previous_post_sort_custom_sort’); function wpse96670_get_previous_post_join_custom_sort($join) { global $wpdb; return … Read more

Trying to add script to specific admin page is not working

I think you’re using the wrong approach. Rather than removing the submenu item, alter how the post type was registered, and change the show_in_menu argument. Hook into init way late and change the argument. <?php add_action(‘init’, ‘wpse99123_post_type_switcher’, 999); function wpse99123_post_type_switcher() { global $wp_post_types; $wp_post_types[‘contact’]->show_in_menu = true; // put it back in the menu } Then, … Read more

Using pre_get_posts to filter one loop in a multiloop archive

Add the filter where you need it and remove it afterwards. add_action(‘pre_get_posts’,’blog_filter’); // your query; presumably WP_Query // your first loop remove_action(‘pre_get_posts’,’blog_filter’); // another query; presumably WP_Query // your second loop You can also make your action self-removing: function blog_filter($query) { remove_action(‘pre_get_posts’,’blog_filter’); if ( !is_admin() && $query->is_main_query() ) { if ($query->is_post_type_archive(‘rg_blog’)) { $query->set(‘post_type’, ‘post’); } … Read more