Get all Custom Post Types

Easy list filtering There’s the global $wp_post_types which is used for e.g. in get_post_type_object( $name );, register_post_type(), etc. If you want to omit the ones delivered with core, you should filter the returned list and skip everything that has the _builtin key set to true. Just use wp_list_filter() for that $cpts = wp_list_filter( $GLOBALS[‘wp_post_types’], array( … Read more

How to Display CPT Posts on index Page

Add a function hooked to pre_get_posts which modifies post_type argument of the main query to add your custom post type. function wpd_home_post_types( $query ){ if( $query->is_home() && $query->is_main_query() ){ $query->set( ‘post_type’, array( ‘post’, ‘natural_food’ ) ); } } add_action( ‘pre_get_posts’, ‘wpd_home_post_types’ );

How would I get this to work – send to post from thick box

The correct way to do this is to: $(‘#upload-background-image-one’).click(function() { formfield = $(‘#background-size-one’).attr(‘name’); tb_show(”, ‘media-upload.php?type=image&TB_iframe=true’); // Take the selected image and insert only the src path into the text field. window.send_to_editor = function(html) { img_url = $(‘img’, html).attr(‘src’); $(‘#background-size-one’).val(img_url); tb_remove(); } return false; }); because when you click on a button you instantiate a call … Read more