Extend taxonomy term page with other posts

Ok I find a solution. I use posts_where filter in pre_get_posts. With this filter I can remove the term related WHERE part from the default SQL query. function custom_loops($query) { if (is_tax( ‘service_photo_location’ )){ $query->set( ‘posts_per_page’, 10); $query->set( ‘post__in’, $ids); $query->set( ‘orderby’, ‘title’); $query->set( ‘order’, ‘ASC’); add_filter( ‘posts_where’, function ( $where ) { $where = … Read more

Use Tags to Query Associated Multiple Posts and Get The Average Of Custom Field Values

If you use those custom fields only for the company tagged posts, then it’s sufficient to retrieve the custom fields without worrying about posts and tags: $tags = array(‘Professional Rating’, ‘Efficiency Rating’, ‘Referral Rating’); foreach ($tags as $tag) { $result = $wpdb->get_col( “SELECT meta_value FROM wp_postmeta WHERE meta_key = ‘$tag'” ); $avg = empty($result) ? … Read more

How to show amount of post in a taxonomy with advanced custom fields?

You can use this code for getting number of posts in a taxonomy: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘your-taxonomy-name’, ‘field’ => ‘slug’, ‘terms’ => ‘some-slug’, ) ) ); $query = new WP_Query( $args ); echo $query->post_count;

List active taxonomy terms

Well I did it.. <ul id=”filter”> <li><a href=”#” class=”current” data-filter=”*” title=””>*</a></li> <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); ?> <?php $term_id = $term->term_id; $taxonomy_name=”categories”; $termchildren = get_term_children( $term_id, $taxonomy_name ); foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); echo ‘<li><a href=”#” data-filter=”.’ . $term->slug … Read more

Object of class WP_Query could not be converted to int inside shortcode

I rewrote the function based on a few other posts I have seen online and now have the following code which works without any errors. I am still open to any further suggestions on the best way to streamline this code even further it it can be. Thanks again function downloads_shortcode($atts){ extract(shortcode_atts(array( ‘download_type’ => ” … Read more

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