How to break up php code to avoid echo

You have an extra “}”, there must be two such braces for two for each loops. Also you need to have endif; statement at end after endwhile. Parsing error may be due to extra “}”. Please try below code and let us know if it works. <?php $custom_terms = get_terms(‘videoscategory’); $other_custom_terms = get_terms(‘product_category’); foreach ($custom_terms … Read more

WP_Query order custom post type with certain meta key value by post modified date

There is an ORDER BY clause in that query that should not have been generated by those arguments. Plus, it doesn’t look like a WordPress query– note the capitalization. WordPress tends to use all uppercase for SQL functions and operators. I suspect that there is a filter on posts_orderby or posts_clauses that is altering that … Read more

Problem retrieving informations and displaying desired structure with custom post type and taxonomy

For question 1, use a custom field when you create the page and use the same template each time. Here is an example using a custom field named house_type. <?php // Template Name: House Type [ … ] $house_type = get_post_meta( get_queried_object_id(), ‘house_type’, true ); $args = array ( ‘post_type’ => ‘house’, ‘orderby’ => ‘meta_value’, … Read more

making php value numeric

Your question is more about SQL than WordPress. If you want to sort your term names as numbers, you can in general try SELECT * FROM wp_terms ORDER BY name+0 ASC or SELECT * FROM wp_terms ORDER BY name*1 ASC or use CAST: SELECT * FROM wp_terms ORDER BY CAST(name AS SIGNED) ASC where you … Read more

How to Control CSS Class Visiblity From WordPress Admin Panel based on Tax Terms

This question is not very detailed but I think you are talking about hiding parts of the markup for a post. If that is the case then has_term should be what you want. if (!has_term(‘Hback’,’tax-slug’)) { // markup that does not show for ‘Hback’ } ‘tax-slug’ is the taxonomy– a WordPress core taxonony like ‘post_tag’ … Read more

Display 3 recent posts from one taxonomy

You should use Taxonomy Parameters available in WP_Query. For example, to get the three recents magazine_entry posts having the international term slug, you can use: $args = array( ‘post_type’ => ‘magazine_entry’, ‘posts_per_page’ => 3 ‘tax_query’ => array( array( ‘taxonomy’ => ‘division’, ‘field’ => ‘slug’, ‘terms’ => ‘international’ ) ) ); $query = new WP_Query( $args … Read more