You can use the WordPress Types Plugin to create custom groups of posts/pages type objects, which include the standard title, body WYSIWYG and featured image (or not), along with any number of any types of fields, checkbox, radio buttons etc. etc.
Then you can use PHP/ Widgets on pages to output categories of data items
This will output all
$pid = get_the_ID(); $argsDeals = array( 'post_type' => 'product-data-set', 'post_status' => 'publish','posts_per_page' => 50, 'meta_query' => array( array( 'wpcf-featured-item-list' => 'checkbox2' ,'value'=>'checkbox2' ,'compare' => 'LIKE' )) ,'meta_key' => 'wpcf-homepage-list-order','orderby' => 'meta_value_num','order' => 'ASC' ); $my_hotdeals = get_posts( $argsDeals ); foreach( $my_hotdeals as $post ) : setup_postdata($post); echo get_the_title($post->ID); echo get_permalink( $post->ID); if ( has_post_thumbnail($post->ID) ) { echo get_the_post_thumbnail($post->ID,'75square-thumb'); } if (get_post_meta( $post->ID, 'wpcf-custom-text',true) != '') { echo get_post_meta($post->ID, 'wpcf-custom-text',true) ; } endforeach; wp_reset_query();
The text in bold is what you change depending on your custom posts/ fields. – they are in order:
- Name of custom post type
- Checkbox group with slug “featured-item-list
- When the specific check box is ticked, the value is set to “checkbox2”
- The homepage-list-order field is a numeric field for ordering the output
- A text field with slug “custom-text”
You can also filter by comparing text fields or radio selectors (selecting a category)
It is the same as above, but instead you change the get post args:
$argsDeals = array( 'post_type' =>'product-data-set', 'post_status' => 'publish','posts_per_page' => 50, 'meta_query' => array( array( 'wpcf-product-name' => 'yes', 'value' => 'item1', ) ),'meta_key' => 'wpcf-priority','orderby' => 'meta_value_num','order' => 'ASC', 'exclude' => $pid2 );
And the fields are similar except product-name is a radio button option which is matched to “item1” and priority is again a numeric field which orders the output.
To get a list of all checkbox values for a current product/ object – use this code to enter the checkbox values into an array:
$catlist = array(); if (get_post_meta( $post->ID, 'wpcf-featured-products',true) != '') { foreach (get_post_meta($post->ID, 'wpcf-featured-products',true) as $key => $value) { foreach ($value as $key2 => $value2) { $catlist[]=$value2; } } } foreach ($catlist as $key => $value) { echo $value . ' '; }
This code would be inside the loop which considers and extracts data for one object
- Checkbox list slug is featured-products
- Array Featured-product ( Array $Key ( $Value2 = checkbox1 ) ) – loop through the inner array and copy to your own array to extract a list of category names
- Print all the checkbox values for the current element you are considering