apply filters only to specific post listing without check the url parameters

Yes, you’re right. There is a clever way. post_row_actions filter can accept also second param $post from which you can get it’s post_type. See the code: add_filter( ‘post_row_actions’, array( $this, ‘remove_row_actions’ ), 10, 2); public function remove_row_actions( $action, $post ) { if ( ‘slider’ === get_post_type( $post ) ) { unset $action[‘view’]; return $action; } … Read more

Display most recent post in full, excerpts of older posts

This is the basic idea behind what you want. Extend/Customize to your liking. if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); // Incrementing a not instantiated variable results in 1 // so there’s no need to set it to 0 beforehand if ( 0 < $is_first_post++ ) the_excerpt(); else the_content(); endwhile; … Read more

Downgrade user from role that allows post creation

You can add actions to the set_user_role hook: add_action( ‘set_user_role’, ‘wpse98904_remove_demoted_user_posts’, 10, 2 ); function wpse98904_remove_demoted_user_posts( $demoted_author_id, $role ) { if( ‘subscriber’ == $role ) { // In here you’d search for all the posts by the user $args = array( ‘numberposts’ => -1, ‘author’ => $demoted_author_id, ‘post_type’ => ‘{your custom post type name}’, // … Read more

Custom Post Templates

I think this approach will work. 1.create template for single post like singlepost.php( default single post template),singlepost-99.php,singlepost-101.php. 2.now put just this code in single.php <?php global $post; get_template_part(‘singlepost’,$post->ID); ?> what this code does check for single post template for current post by post id if not found call singlepost.php. Important Link: get_template_part()

How To Add One Tag to Multiple Posts?

If you have the ability to use wp-cli on a bash-like shell it’s a handy way to do this: for ID in $(wp post list –post_type=post –post_status=any –field=ID); do wp post term add $ID post_tag old; done for ID in $(…); do starts a loop for each line of output of the internal command wp … Read more

how to replace embedded “full” sized images within a post with the “large” ones

I solved my own problem by using the creating a page using the following template. Just create and visit the page using the template below. You will only be viewing the results with primitive pagination, follow the code and it’s easy. Changes will not be saved until you visit /whatever-permalink-you-have/?updating=true Caution Please backup your database … Read more

Only display a certain number of posts, dependent on how many posts there are available in a query

You don’t have to run two queries, as you already got what you want (even more). $args = array ( ‘post_type’ => ‘mytheme_posttype’, ‘post_status’ => ‘publish’, ‘numberposts’ => 12, ); $sliderQuery = new WP_Query($args); $num_posts = $sliderQuery->post_count; if ($num_posts >=4) { if ($num_posts >= 12) $postsToPrint = 12; elseif ($num_posts >=8) $postsToPrint = 8; else … Read more

Add scripts on custom post add/edit pages Not Working

There are a few things you’ll want to do to make you include work and in generally better. Here is the complete code: function my_theme_enqueue_admin_scripts() { $screen = get_current_screen(); // This is how we will check what page we are on if ( in_array( $screen->id, array( ‘post’, ‘page’) ) && $screen->action == ‘add’ ) { … Read more