Display prev / next posts links from the same category with thumbnails in WordPress

So I asked ChatGPT and it comes with a working solution for me: <?php $prev_post = get_previous_post(true, ”, ‘listing_category’); if (!empty($prev_post)) : ?> <a href=”<?php echo get_permalink($prev_post->ID); ?>”> <?php echo get_the_post_thumbnail($prev_post->ID, ‘thumbnail’); ?> << <?php echo esc_html($prev_post->post_title); ?> </a> <?php endif; ?> </div> <div class=”next-post-link”> <?php $next_post = get_next_post(true, ”, ‘listing_category’); if (!empty($next_post)) : ?> … Read more

Is there a way to create a single rewrite rule to handle multiple variables depending on what is present?

I was able to make this work by using a power set function and then using that array to create individual rewrite rules. add_action(‘init’, ‘ebd_custom_rewrite_rules’); function ebd_custom_rewrite_rules() { $taxonomies = array( ‘engine-work’, ‘engine-specialty’, ‘application-specialty’, ‘machining-capability’, ‘dyno-facility’, ‘shop-region’); $combinations = ebd_get_array_power_set($taxonomies); $element_size_min = 2; foreach ($combinations as $combination) { if ($element_size_min <= count($combination)) { // skip … Read more

Hook function when taxonomy terms change

You can avoid infinite loop by removing the action before calling update post function. function maybe_disable_comment($post_id) { // do you check if the post has specific custom tax term. if ( ! has_term( ‘bar’, ‘YOUR_CUSTOM_TAX’, $post_id ) ) { return false; } // remove the filter that will create infinite loop. remove_action( ‘wp_insert_post’, ‘maybe_disable_comment’ ); … Read more