Add a simple php code snippet to redirect a single wordpress url to another

Alright, so I found the solution, it was a simple change in the request object class variable: function redirect_workaround( $request ){ if( $request->request === ‘myspecialurl’ ) { $latest = new WP_Query( array( ‘category_name’ => ‘myspecialcategory’, ‘posts_per_page’ => 1 ) ); if( $latest->have_posts() ){ wp_redirect( get_permalink( $latest->post->ID ) ); exit; } } } add_action( ‘parse_request’, ‘redirect_workaround’ … Read more

How can I filter get_terms with post meta

If you want to output a list of terms that are assigned to the posts in the current query, you could use something like this in your template: global $wp_query; $terms = []; foreach ( $wp_query->get_posts() as $item ) { $item_terms = wp_get_post_terms( $item->ID, ‘web_cat’ ); $terms[] = $item_terms; } $unique = array_unique( array_merge(…$terms), SORT_REGULAR … Read more

500 Internal Server Error PHP 8.1 Array with wordpress

Problem solved (thx a lot to ChrisHaas) replacing echo implode( $terms_array, ”); with echo implode(”, $terms_array); fixed it. Historically the order of these parameters didn’t matter, however as of PHP 7.4 passing the array first was deprecated and it was completely removed in PHP 8.0.