6

I guess you are using Gutenberg in which case this is non-trivial problem. Gutenberg saves post data in two steps (two separate http requests, just use developer tools in your browser to check). First, using REST API it saves Gutenberg-ready fields including title, content and slug. Problem is, REST API uses JSON and $_POST is empty array during this save ...


2

Change you constructor to this public function __construct($post) { $this->set_bio($post->post_content); $thumbnail = get_the_post_thumbnail_url($post->ID); $this->set_thumbnail($thumbnail); } and remove thumbnail code from init method.


1

So thanks to Jacob Peattie and his helpful comments I was able to resolve this issue. meta_key was part of the group, but it wasnt prefixed by a group key. So, something like this totally works for me: group_field_sub_field. So changing that in both arrays did the trick.


1

The code you shared worked fine for me, so either your value for $user_id or $post_type is incorrect - or the user actually has no posts of the post type you're searching for. function get_user_posts_count($user_id, $post_type) { $args['author'] = $user_id; $args['fields'] = 'ids'; $args['post_type'] = $post_type; $args['fields'] ...


1

Use the pre_get_posts hook to modify the $query and include your custom post types in the search. Add the following to your theme's functions.php file. function modify_query( $query ) { if ( is_home() ) { $query->set( 'post_type', array( 'post', 'articles', 'film_descriptions', 'book_descriptions', 'characters' ); } } add_action( '...


1

Find functions.php in your theme and add this code: function add_custom_pt( $query ) { if ( !is_admin() && $query->is_main_query() ) { $query->set( 'post_type', array( 'post', 'cptslug1', 'cptslug2' ) ); } } add_action( 'pre_get_posts', 'add_custom_pt' ); Change array values to match your post type slugs (add as many as you need), but ...


1

In my version of WordPress this error will come from line 46 of wp-admin/post.php, which has: if ( isset( $_POST['post_type'] ) && $post && $post_type !== $_POST['post_type'] ) { wp_die( __( 'A post type mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 ); } The code before that looks pretty ...


Only top voted, non community-wiki answers of a minimum length are eligible