same template for multiple custom post type single

Yes, you can use template_include or the more specific single_template. Example code: add_filter( ‘single_template’, function( $template ) { $cpt = [ ‘america’, ‘nepal’, ‘norway’ ]; return in_array( get_queried_object()->post_type, $cpt, true ) ? ‘path/to/country-single.php’ : $template; } ); single_template filter runs only for singular queries, so you don’t need to check you are on a singular … Read more

Auto set Post to Specific Categories

Here is some rough code for you, you may improve the query if you like… By the way selecting post_title and post_status is not neccessary, but useful if you want to ensure that you are returning the right results via conditional logic within your foreach loop. global $wpdb; $results = $wpdb->get_results( ” SELECT ID, post_title, … Read more

get_permalink executes link without https

this may be called as a bug in get_permalink, but it may not be. I had the same case, and when I tried to echo site_url(); I get the https://… But once I updated the options for siteurl and home to have https get_option( ‘siteurl’ ); get_option( ‘home’ ); get_permalink worked fine. I noticed that … Read more

Pagination – Posting First Page Content

Try to update index.php template with new WP_Query arg paged. The code should be: <?php $paged = isset(get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $news_query = new WP_Query(array( ‘post__not_in’ => array($featured_post->ID), ‘paged’ => $paged )); More info in codex

Remove some articles from the list in WPAdmin for a user

This could done with couple of ways: With pre_get_posts Small modification will need it like the actual meta value names function alter_edit_php_query_remove_posts($query) { $screen = get_current_screen(); if(is_admin() && $screen->post_type == ‘post’) { $current_user = wp_get_current_user(); $key = ‘nickname’; $single = true; $user_meta_value = get_user_meta( $current_user->ID, $key, $single); $meta_query = array( array( ‘key’=>’_edit_last’, ‘value’=>$user_meta_value, ‘compare’=>’=’, ), … Read more

ping_status in JSON REST API

According to WordPress Codex, pings tells Whether the current post is open for pings. In human words, A ping is a “this site has new content” notification that invites search engine bots to visit your blog. For more info, have a look at this blog article.

Hide add new page button

This can be achieved easy enough with just CSS. First we are going to add a function that will output a class to the body tag based on what role the user is. Then we will enqueue a stylesheet to show up in the admin. Then use the class in the body to target and … Read more