Warning after create Custom post type with Roots theme
-
29-11-2019 - |
Question
I've created e Custom post type with Roots theme, adding the custom script inside functions.php like
require_once locate_template('/lib/custom-post-types.php'); // Custom post types
After that in backend the list of pages is not displayed, and in frontend show this Warning:
Warning: strpos() expects parameter 1 to be string, array given in /wordpress/wp-includes/query.php on line 2375
Warning: urldecode() expects parameter 1 to be string, array given in /wordpress/wp-includes/post.php on line 3901
Warning: urlencode() expects parameter 1 to be string, array given in /wordpress/wp-includes/formatting.php on line 3690
What could be?
Solution
Solved, it was a problem with the custom-post-types.php I was calling the type with the name 'post_type'
changed that solved the issue.
OTHER TIPS
Create custom post type by writing below code in function.php file located in Apperance => Editor . This code is very simple example of custom post type.
// custom post type function
function create_posttype() {
register_post_type( 'movies',
// CPT Options
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'movies'),
)
);
}
// Hooking up function for theme setup
add_action( 'init', 'create_posttype' );
Reference : How to Create Custom Post Types in WordPress – WordPress Tutorial