show custom value from frontend form in a post (custom post type)

Refer to the parameters section in the documentation for wp_insert_post. Custom fields (meta data) must be passed in the form of a key/value array with the parameter name ‘meta_input’. Change ‘post_custom_field’ => $add to ‘meta_input’ => array( ‘post_custom_field’ => $add ) To show the value, use the get_post_meta function. get_post_field is only for the native … Read more

Specifying meta field’s column type in Database using add_post_meta

When you use add_post_meta, no column in database is created. All post meta data is stored in wp_postmeta table (https://codex.wordpress.org/Database_Description#Table:_wp_postmeta). Here’s the structure of that table: post_id is the ID of post that this meta data is assigned to meta_key is the key of meta (in your case favourite_fruit_code) meta_value is the value of that … Read more

Get an array wich contains the post_name of every post that has the custom post_type “pelicula”

<?php // query for your post type $post_type_query = new WP_Query( array ( ‘post_type’ => ‘pelicula’, ‘posts_per_page’ => -1 ) ); // we need the array of posts $posts_array = $post_type_query->posts; // create a list with needed information // the key equals the ID, the value is the post_title $post_title_array = wp_list_pluck( $posts_array, ‘post_title’, ‘ID’ … Read more

Is it possible to show multiple (custom) post types at the wp homepage only by using pluging code?

Something like this should achieve your goal. You may need to remove the is_main_query() check depending on where you want this to show up though. add_filter(‘pre_get_posts’, ‘projects_are_posts’); function projects_are_posts($query) { if (is_admin() || !is_main_query() ) { return $query; } $types = $query->get(‘post_type’); if (!is_array($types)) { $types = array($types); } if (in_array(‘post’, $types) && !in_array(‘projects’, $types)) … Read more