How to get post taxonomy url and name in wp_query

Please try this <div class=”post-category”> <?php // @ https://developer.wordpress.org/reference/functions/get_the_terms/ $terms = get_the_terms( get_the_ID(), ‘video-category’ ); if ( $terms && ! is_wp_error( $terms ) ){ $term_links = array(); foreach ( $terms as $term ) { $term_links[] = ‘<a href=”‘ . esc_attr( get_term_link( $term->slug, $taxonomy ) ) . ‘”>’ . __( $term->name ) . ‘</a>’; } $all_terms … Read more

loop hierarchical custom post type, child pages only

<?php // query only child pages of custom post type $customQuery = array( ‘post_type’ => ‘CUSTOM_POST_TYPE’, ‘posts_per_page’ => ’10’, ‘post_parent__not_in’ => array(0), ); $custom = new WP_Query( $customQuery ); if ($custom->have_posts()) : while ( $custom->have_posts()) : $custom->the_post(); ?> DO STUFF <?php endwhile; endif; wp_reset_query(); ?>

after refresh the id that shows correct in first time click, changes to 1

It’s because you’re not outputting the ID into data-like: data-like=”<?php echo isset($existQuery->posts[0]->ID); ?>” You are outputting whether the ID isset(), which is true, which is being turned into 1. You need to output the actual ID: data-like=”<?php echo isset( $existQuery->posts[0]->ID ) ? esc_attr( $existQuery->posts[0]->ID ) : ”; ?>”

How to put posts with some taxonomy on top of others in `pre_get_posts`

You could try modifying the tax query to use the relation parameter and add a second clause that matches any post that does not have the matched string value in the meta array. See Taxonomy Parameters. EDIT: Thank you for pointing that out, Tom. You’re correct, I’ve updated to reflect. function group_matched_posts_at_top( $query ) { … Read more

Best performance for use Custom Field in WP

Neither will be faster because the root of the performance problem is the WP table design, not the plugin. The post meta table is optimised for finding values when you already know the post ID/keys, it’s not designed for searches, though there are mitigations. Searches/grouping/finding is what the taxonomy tables were created for. Finding all … Read more

Custom query with custom filtering returning incorrect results

Your query syntax looked good, although you could instead add a direct meta/taxonomy query clause array such as $meta_query[] = array( ‘key’ => ‘_price’, … ) instead of $meta_query[] = array( ‘relation’ => ‘AND’, array( ‘key’ => ‘_price’, … ) ). However, I spotted 2 main issues with your code: Issue 1: Your custom pagination … Read more