Automatic Set Category For A Custom Post Type

Ok after some research and tests this is the solution I coded function auto_set_event_categories ( int $post_ID ){ //Post Type of Tribe Events $post_type = “tribe_events”; //If it is not an Event, exit if( get_post_type($post_ID) != $post_type){ return; } //Get the values of the custom fields $customfields = tribe_get_custom_fields ( $post_ID ); //Extract the relevant … Read more

Adding a Section for Visitors

This forum is to get answers to (technical) problems, whereas you are asking for opinions. The “challenge” you’re having can be solved in different ways. For starters the comment form could be used and it should be possible to add additional fields. See add_comment_meta() (https://codex.wordpress.org/Function_Reference/add_comment_meta) Another way could be to add use a form to … Read more

Custom fields multiple commas separated values

It’s not supposed to. If you want to use multiple values in an IN meta query you need to pass an Array. That would look like this: $Style_Cabinet_Style = array( ‘Demo’, ‘Demo Two’ ); If you only have a String with commas separating the values, eg. ‘Demo, Demo Two’. Then you can use explode() to … Read more

Post Filtered by Custom Field Value

Took the advice and decided not to reinvent the wheel. Created a taxonomy specific for products called Product categories. Added the following code to my functions.php. add_action(‘init’, ‘products_categories’, 0); function products_categories(){ $labels = array (‘name’ => _x(‘Product Categories’,’taxonomy general name’), ‘singular_name’ =>_x(‘Product Category’,’taxonomy singular name’), ‘serch_items’ => __(‘Search Product Categories’), ‘popular_items’ => (‘Popular Product Categories’), … Read more

How to get all wp_posts in wordpress fetched from database

More explain your question. if you want to fetch all post in database you this code $query = array( ‘post_type’ => ‘my-post-type’, ‘post_author’ => $current_user->ID, ‘post_status’ => array(‘publish’, ‘pending’, ‘draft’, ‘auto-draft’, ‘future’, ‘private’, ‘inherit’, ‘trash’) ); $loop = new WP_Query($query); while ( $loop->have_posts() ) : $loop->the_post();