Sizing textarea field in custom metabox

You could try styling it with CSS by adding an ID or a class to the textarea and inserting styles into the wp_admin head. Or, a quick way would be to do something like this : echo ‘<textarea name=”_dresscode” class=”widefat” style=”width:400px !important; height:80px !important;” >’ . $dresscode . ‘</textarea>’; If not, have you tried simply … Read more

Global custom meta box

In addition to the other answers, you can further improve it by looping through an array of types instead of manually adding a new add_meta_box() line each time you add a new type. $postTypes = array( ‘custom-post-type1’, ‘custom-post-type2’, ‘custom-post-type3’ ); foreach( $postTypes as $pt ) add_meta_box( ‘adv_form_box1’, ‘Advanced Form’, ‘adv_form1’, $pt, ‘side’, ‘high’ );

Custom “radio button meta box” not saving correctly

The error is in you saving function where you are looking for $_POST[‘meta_box_musicreleases_linktype’] which is never set and should actually be $_POST[‘linktype’], and the use of wp_kses is not right here, if you want to validate the data and you know all of the accepted values the you can simply use in_array try: add_action( ‘save_post’, … Read more

How to sort posts in a custom post type by title in ascending order by default?

You should use pre_get_posts: add_action(‘pre_get_posts’,’wpse56753_businesses_default_order’); function wpse56753_businesses_default_order( $query ){ if( ‘business’ == $query->get(‘post_type’) ){ if( $query->get(‘orderby’) == ” ) $query->set(‘orderby’,’title’); if( $query->get(‘order’) == ” ) $query->set(‘order’,’ASC’); } }

Does WP have a global of $id?

If you are using netbeans and xdebug, or have set up your debugging environment correctly then you can observe the variables, objects e.t.c as they change. To see when they are created and what is contained within objects such as wp_query or wp_rewrite your posts->ID is set once the function wp() is called in wp-blog-header.php. … Read more

My archive-posttype.php template is not loading

as determined in the comments, the page URI is ?post_type=photos&genre=boudoir… The reason why “archive-{$post_type}.php” isn’t used in this case is because the page is a taxonomy archive and not a custom post type archive. WordPress is looking for taxonomy-genre.php instead of archive-photos.php, and not finding it, is defaulting back to good old archive.php. Here’s a … Read more

Specifying Mouseover Icon for Custom Post

This is more of a CSS question. However, if you create your icon as CSS sprite, you just shift between versions of it in your CSS. Something like: #toplevel_page_my_item .wp-menu-image { background: url(‘images/sprite.png’) no-repeat 0 8px !important; } #toplevel_page_my_item:hover .wp-menu-image, #toplevel_my_item.wp-has-current-submenu .wp-menu-image { background-position: 0 -24px !important; }

Display custom post function ONLY if it has a value [closed]

<td> <?php $review_link = get_post_meta( get_the_ID(), ‘game_review_link’, true ); if ( ! empty( $review_link ) ) : ?> <a href=”https://wordpress.stackexchange.com/questions/110077/<?php echo esc_html( $review_link ); ?>”> <div class=”rating-<?php echo esc_html( $review_link ); ?>”> <?php echo esc_html( $review_link ); ?> </div> </a> <?php endif; ?> </td> UPDATE Thanks to Chip Bennet, this is now working code. Changed … Read more