URL rewrite rule

function custom_rewrite_rules() { add_rewrite_rule( ‘^product_brand/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?product_brand=$matches[1]&page=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^product_brand/([^/]+)/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?product_brand=$matches[1]&product_cat=$matches[2]&page=$matches[3]’, ‘top’ ); add_rewrite_rule(‘^product_brand/([^/]+)/([^/]+)?’, ‘index.php?product_brand=$matches[1]&product_cat=$matches[2]’, ‘top’); add_filter( ‘query_vars’, function( $vars ){ $vars[] = ‘product_brand’; $vars[] = ‘product_cat’; return $vars; } ); } add_action(‘init’, ‘custom_rewrite_rules’); and pagination add_action( ‘pre_get_posts’, function() { $page = get_query_var(‘page’); $query->set( ‘paged’, $page ); return $query; } );

Trying to publish a little bit of Javascript on the homepage AND at the bottom

You can use the functions is_front_page() or is_home() depending on what your home page is. Also instead of wp_head you can use wp_enqueue_scripts Your code will look something like this function add_inline_script() { if(is_home() || is_front_page) wp_enqueue_script(‘js-handler-name’, ‘js-url’); } add_action( ‘wp_enqueue_scripts’, ‘add_inline_script’);

How to apply ‘add two more posts’ to media content?

First, modify your example by specifying post type post and removing the cat and post__not_in arguments. Next, if you want to make sure you’re looking at the parent’s date and not the media’s date, you’ll also need to make sure to have a fallback in case someone tries to view an image that isn’t attached … Read more

Get user by meta data key and velue

This how my stored data function is for this meta group and get data stored $certification = array( ‘course_id’ => $certificate_id, ‘course’ => $certificate, ‘date’ => $date, ‘instructor’ => $certifying_instructor, ‘school’ => $school, ‘last_update’ => date(‘d-m-Y’), ); add_user_meta( $user_ids, ‘certifications’, $certification ); and this get data $users_detail = get_user_meta($user_id); $certificates = $users_detail[‘certifications’]; $n_course_id = array(); … Read more

Send Notification after post published was working but stopped after the last WP update

Regarding Update 1. Perhaps you could compare the publish and modified dates and run your code only when they match, i.e. when the post is first published. Something along these lines, function to_followers_only_notify( $ID, $post ) { $posted = strtotime( $post->post_date ); $modified = strtotime( $post->post_modified ); if ( $posted !== $modified ) { return; … Read more