Querying terms with calculations based on term meta data, sql vs. get_terms
Querying terms with calculations based on term meta data, sql vs. get_terms
Querying terms with calculations based on term meta data, sql vs. get_terms
i suggest you check the the value of $checkbox by either checking checkbox under meta_key column in wp_postmeta or *your prefix_postmeta table in your database or simply do var_dump($checkbox); for testing if its 0 or null or an empty string or so then your if condition will not return true and $has_video will not be … Read more
Try to do this: $args = array( ‘taxonomy’ => ‘kategorien’, ‘orderby’ => ‘slug’, ‘order’ => ‘ASC’, ‘hide_empty’ => true, ‘meta_key’ => ‘YOUR_KEY_VALUE’, ‘meta_value’ => true ); $terms = get_terms( $args );
You can save term meta using update_term_meta: update_term_meta( int $term_id, string $meta_key, mixed $meta_value, mixed $prev_value=”” ) https://developer.wordpress.org/reference/functions/update_term_meta/
The mistake is with this line: // Add the school ID as a meta data add_user_meta( $user_id, ‘school_id’, [$school_id] ); No need for the array brackets when you store the user meta, change it to: // Add the school ID as a meta data add_user_meta( $user_id, ‘school_id’, $school_id );
Meta Query | Compare category name and meta value
only the first meta field is used Yes, and it’s because the $new_slug contains just one meta which is maker. So if you want to add other meta like model and year, and have a slug that looks like <maker>-<model>-<year>, you can try my code below — just replace the $new_slug = get_post_meta($post_id,’maker’, true); in … Read more
Query to show post current day
Try this. I followed the WP_Query docs to build this. $args = [ ‘meta_query’ => [ ‘relation’ => ‘AND’, [ ‘_stock_status’ => [ ‘key’ => ‘_stock_status’, ‘compare’ => ‘EXISTS’, ], ‘_sale_price’ => [ ‘key’ => ‘_sale_price’, ‘compare’ => ‘EXISTS’, ], ‘_price’ => [ ‘key’ => ‘_price’, ‘compare’ => ‘EXISTS’, ] ] ], ‘orderby’ => [ … Read more
If the custom field will be always empty when there is no pdf file, you can check if it is not empty before displaying the link: <?php $pdf_name = get_post_meta($post->ID, ‘pdf_name’, true); if($pdf_name) { ?> <a class=”pdfDownload” href=”<?php bloginfo(‘url’); ?>/wp-content/uploads/<?php echo $pdf_name; ?>”>PDF Download</a> <?php } ?> But, if there is a possibility that the … Read more