Change admin post thumbnail size for custom post type only

admin_post_thumbnail_size takes three parameters: $thumb_size: selected Thumb Size if you do nothing in the filter. $thumbnail_id: Thumbnail attachment ID. $post: associated WP_Post instance So you may make use of these parameters to have a better control in your CODE. Use the CODE like below: function custom_admin_thumb_size( $thumb_size, $thumbnail_id, $post ) { if( ‘slider’ === $post->post_type … Read more

Display Post Author for Custom Post Type in Edit-Post Screen

You can achieve this by using the add_post_type_support function as described here: https://codex.wordpress.org/Function_Reference/add_post_type_support. This code should work: function add_author_support_to_posts() { add_post_type_support( ‘your_custom_post_type’, ‘author’ ); } add_action( ‘init’, ‘add_author_support_to_posts’ ); It can be added in your theme’s function.php file.

WordPress is executing URL in code when called via wp_mail()

Please try the following, I think having a return from the site_url() function could be creating a problem with the $confirm_url variable. That and you have an unescaped slash in your url. $site_url = site_url(); $confirm_url = $site_url. ‘\/verification?id=’ . $post_id . ‘&hash=” . $hash; // Send a verification e-mail to the user to confirm … Read more

Query for custom posts with a specific tag slug

Since tag is a taxonomy of a custom_post post type, the query could look like this: <?php $args = array( ‘post_type’ => ‘custom_post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘tag1’, ‘tag2’, ), ), ), ); $posts = new WP_Query( $args ); See WP_Query Taxonomy Parameters.

Prevent change with new query_posts()

You shouldn’t be using query_posts() at all. From the documentation: Note: This function will completely override the main query and isn’t intended for use by plugins or themes. Its overly-simplistic approach to modifying the main query can be problematic and should be avoided wherever possible. In most cases, there are better, more performant options for … Read more

Display custom taxonomy as dropdown list

Below is the easiest solution I use for displaying custom taxonomy as the dropdown instead of checkboxes. 1/ Use third party WordPress plugin ‘ACF’ to create the taxonomy ‘Relational’ field type and display it as dropdown as shown in below screenshot. https://wordpress.org/plugins/advanced-custom-fields/ For displaying taxonomy selected you can refer documentation of ACF for relational taxonomy … Read more

Redirect a page based on last word in slug

There are many solutions for that.. 1. .htaccess rules You can put some redirect rules in your .htaccess file: RewriteRule ^(.*)\-staff/$ /staff/? [L,R=301] // some other rules 2. Using WordPress hooks function my_redirect_function() { global $wp; if ( preg_match( ‘@staff/?$@’, $wp->request ) ) { wp_redirect( get_post_type_archive_link( ‘staff’ ) ); die; } // … put other … Read more