can't query custom post type by post_name (slug)
-
Hi, I would need some help with WordPress and custom post types/ permalinks.
I registered custom post type by the name “services” with the following arguments:
$args = array( 'labels' => $labels, 'singular_label' => __('services'), 'public' => true, 'query_var' => true, 'show_ui' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/img/wp-menu-ico.png', 'menu_position' => null, 'capability_type' => 'page', 'hierarchical' => false, 'rewrite' => array( 'slug' => 'services', 'with_front' => true ), 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes' ) );
Then I created new custom post/service by the title of “Make up” and slug “make-up”. When I try to preview this post from WP dashboard using the Preview link it gives me 404. I can’t query this post from outside the dashboard too.
Now I found that when I use the following url structure it shows me the post: /?post_type=services&p=243
This however doesn’t work: /?services=make-up
Checked my mysql table and the post by id of 243, post_name “make-up” and post_type “services” exists.
What I’m trying to do is to use pretty urls with custom post type, which doesn’t work. I disabled the pretty permalinks in WP options and still doesn’t work.
Any ideas what am I doing wrong?
- The topic ‘can't query custom post type by post_name (slug)’ is closed to new replies.