Proper way to handle GET and POST request in WordPress
<?php add_action(‘init’,’handle_your_reqest’); function handle_your_request(){ if (isset($_REQUEST[‘your-key’])): // Your Code Here exit; endif; }
Read moreBootstrap 4 Pagination for WordPress
Copy wordpress-bootstrap-4-pagination.php from https://github.com/renzramos/wordpress-bootstrap-4-pagination Add boostrap_4_pagination() to your archive page. It’s also supported bootstrap 5 (https://getbootstrap.com/docs/5.0/components/pagination/)
Read moreCreate Custom Post Type for WordPress
Add this to your theme functions.php function theme_slug_register_post_type() { $labels = array( ‘name’ => _x( ‘Referrals’, ‘post type general name’, ‘theme-slug’ ), ‘singular_name’ => _x( ‘Referral’, ‘post type singular name’, ‘theme-slug’ ), ‘menu_name’ => _x( ‘Referrals’, ‘admin menu’, ‘theme-slug’ ), ‘name_admin_bar’ => _x( ‘Referral’, ‘add new on admin bar’, ‘theme-slug’ ), ‘add_new’ => _x( ‘Add […]
Read moreHow to use WordPress Rewrite API?
Complete tutorial – Coming Soon function custom_rewrite_basic() { add_rewrite_rule(‘^products/([^/]*)/reviews/([^/]*)’, ‘index.php?product-slug=$matches[1]&product-child=reviews&product-comment-key=$matches[2]’, ‘top’); } add_action(‘init’, ‘custom_rewrite_basic’); function prefix_register_query_var( $vars ) { $vars[] = ‘product-slug’; $vars[] = ‘product-child’; $vars[] = ‘product-comment-key’; return $vars; } add_filter( ‘query_vars’, ‘prefix_register_query_var’ ); function prefix_url_rewrite_templates() { if ( get_query_var( ‘product-slug’ ) && get_query_var( ‘product-child’ ) == ‘reviews’ && get_query_var( ‘product-comment-key’ )) { $product_slug […]
Read moreWordPress: How to add author and publisher meta tag?
Add the following to your header.php or you can use wp_head() action to these codes. $post_author_id = get_post_field( ‘post_author’, get_the_ID() );
Read morePage Alternative Links for WordPress
Simple plugin to add alternative links to your existing pages. Sometimes if we want to change the page url, we don’t want to lose the url ranking in Google. This plugin will allowyou to change the page url and the alternative links (old link; depending on the scenario) on it. Features Unlimited alternative link to your existing page Canonical tag […]
Read more