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

Display CPT index page as front/home page

Rename portfolio-archive.php to front-page.php and change the post type for that page with a filter on pre_get_posts: add_filter( ‘pre_get_posts’, ‘wpse_99860_portfolio_on_front’ ); function wpse_99860_portfolio_on_front( $query ) { // not the main loop if ( ! $query->is_main_query() ) return $query; // not the front page if ( ! $query->is_front_page() ) return $query; $query->set( ‘post_type’, array ( ‘portfolio’ … 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

Save Custom Fields

I solved the problem with this code by creating again de meta box: // Add the Meta Box function add_custom_meta_box() { add_meta_box( ‘custom_meta_box’, // $id ‘Product Requirements’, // $title ‘show_custom_meta_box’, // $callback ‘produktkrav’, // $page ‘normal’, // $context ‘high’); // $priority } add_action(‘add_meta_boxes’, ‘add_custom_meta_box’); // Field Array $prefix = ‘custom_’; $custom_meta_fields = array( array( ‘label’=> … Read more

How to fetch posts that are stored in the different table than (default) wp_posts?

Don’t hack the Core. There are filters in WP_Query that should more than suffice to include your table, if your SQL and regex are good enough. posts_distinct – Alters SQL ‘DISTINCTROW’ clause to the query that returns the post array. posts_groupby – Alters SQL ‘GROUP BY’ clause of the query that returns the post array. … 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

cannot achieve this structure (custom posts VS categories VS ??)

This is fairly straightforward with a custom post type and custom taxonomy. First, register a custom taxonomy worktype, with rewrite parameter set to works: ‘rewrite’ => array( ‘slug’ => ‘works’ ) Next, register a custom post type with rewrite set to works/%worktype%: ‘rewrite’ => array( ‘slug’ => ‘works/%worktype%’ ) You’ll also need to set with_front … Read more