Warning: Undefined variable $post in C:\xampp\htdocs\… after PHP upgrade
Warning: Undefined variable $post in C:\xampp\htdocs\… after PHP upgrade
Warning: Undefined variable $post in C:\xampp\htdocs\… after PHP upgrade
As Sally CJ suggest in comments, the error come from the terms with artist_avatar empty. So, check if is_array() before access the array, fix it: add_filter(‘manage_artist_custom_column’, function ($content,$column_name,$term_id){ $term = get_term($term_id, ‘artist’); $avatar = get_field(‘artist_avatar’, $term); switch ($column_name) { case ‘artist_avatar’: if ( is_array( $avatar ) ) { $content = $avatar[“url”]; } else { $content … Read more
get_the_terms() will always return an array; but because you have only one ‘project_category’, you can simply use its first element: add_shortcode( ‘return_taxonomy_slug’, ‘my_shortcode_return_taxonomy_slug’ ); function my_shortcode_return_taxonomy_slug() { $terms = get_the_terms( get_the_ID(), ‘project_category’); return $terms[0]->slug; }
Rewrite Search URL Permalink For CPT Custom Taxonomies
Problems using get_the_terms in a plugin
when custom taxonomy is empty, the page won’t load
I think you can’t with orderby and rand. Instead you could create a custom table where you generate random integer values and connect them to the posts table. Then use posts_join filter to join your custom table to the posts query and then use posts_orderby filter to order by your joined random field. Now your … Read more
update attribute of specific products in woocommerce
What you need is to add a tax_query to your WP_Query arguments, where you check that your taxonomy exists on the posts you are querying. Here is an example that fetches the 3 latest published posts that have the taxonomy site set. $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, ‘tax_query’ … Read more
First of all, you can do foreach inside foreach. In fact, you can nest loops to much higher level based on your server configuration. If you are going to use only one term in that field, make sure you select Field Type as Radio or Select and Return Value as Term Object. In that case, … Read more