Custom icons for Custom Post Type category lists

If your theme uses body_class and post_class then you should have CSS enough to do this. Make a <div> for your icon. <div class=”mycategoryicon”></div> Add some style. .category-slug .mycategoryicon { height:32px; width:32px; background:#ffffff url(‘slug-icon.jpg’) no-repeat; } The “slug” part of the class name should be your actual category slug. Height and width can of course … Read more

Help with custom post type and custom taxonomy issue with rewrites

I believe you have a problem with the arrays you’re passing to register_taxonomy. You have: register_taxonomy( ‘book-cats’, array( ‘books’ ), array( ‘hierarchical’ => false, ‘label’ => __( ‘Book Categories’, ‘sp-theme’ ), ‘singular_label’ => __( ‘Book Category’, ‘xxr’ ), ‘query_var’ => true ) ); It should be something like… register_taxonomy( ‘book_cats’, array( ‘books’ ), array( ‘hierarchical’ … Read more

Prevent users from changing post status

Add this code where it’s should be (plugin/functions.php/mu-plugin) – simple “hide” method using css. add_action(‘admin_print_styles-post.php’, ‘hide_publishing_block_using_css’); add_action(‘admin_print_styles-post-new.php’, ‘hide_publishing_block_using_css’); function hide_publishing_block_using_css(){ echo ‘<style>#misc-publishing-actions{display:none;}</style>’; }

How to query custom post then display sections by meta value

I would recommend executing two separate queries, each one differing from the other via a meta_query against your post custom meta key value. $current_query_args = array( ‘post_type’ => ‘recipient’, ‘meta_query’ => array( array( ‘key’ => ‘yes_current’, ‘value’ => ‘on’, ‘compare’ => ‘=’ ) ) ); $current_query = new WP_Query( $current_query_args ); if ( $current_query->have_posts() ) … Read more

How can I sort posts ascending by post title for a specific post type, but on a category archive template?

You can use pre_get_posts to hook in and change the query. The argument passed to pre_get_posts is the query object. It fires for every query, so you need to check some things first. Quick example (not-tested) — change the order on only the video type’s post type archive page. <?php add_action(‘pre_get_posts’, ‘wpse73991_change_order’); function wpse73991_change_order($q) { … Read more

Create a Page Templete to Display Table Of Content for Custom Taxonomies

Here is the final code I managed to working out: <div class=”content” role=”main”> <?php $term = get_term_by(‘slug’, get_query_var(‘term’), get_query_var(‘taxonomy’)); echo ‘<h3 class=”tax-title”>’ . $term->name . ‘</h3>’; ?> <div id=”TableOfContents”> <div class=”ui-boxmenu”> <ul class=”sections”> <?php $taxonomyName = “tableofcontent”; $parent_terms = get_terms($taxonomyName, array( ‘parent’ => $term->term_id, ‘orderby’ => ‘menu_order’, ‘hide_empty’ => false )); foreach ($parent_terms as $pterm) … Read more