Array terms, if term one, if term two, etc

I solved it like this. Although if there are more than 3 co-authors problems could arise $tagx = get_the_terms($post->ID , ‘autoria’); $number = count($tagx); if ( $number == 1) { $first_author = $tagx[0]; echo ‘<strong>’; echo esc_html( $first_author->name ); echo ‘</strong>’; } if ($number == 2) { $first_author = $tagx[0]; $second_author = $tagx[1]; echo ‘<strong>’; … Read more

Custom taxonomy still using query URL after fixing error

To address the issue of your custom taxonomy resource-category not displaying correctly even after fixing the custom post type and flushing permalinks, you can follow these steps: Double-check the Registration Code. Flush Permalinks Again: Go to Settings > Permalinks and click on Save Changes. This will flush the rewrite rules and update the permalinks. Clear … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)