0

Any ways I could show Custom Post Type's Content with such URL? E.g: (www.mydomain.com/view-promotion/christmas-promotion)

  • view-promotion is page name
  • christmas-promotion is the custom post type's post name

Currently this URL (www.mydomain.com/view-promotion/christmas-promotion) is automatically changed to (www.mydomain.com/promotion/christmas-promotion) where (promotion) is the post_type.

I am trying to have the view-promotion (Page Template) to show content by using custom post type name.

0

You can use a slug, when you are registering the post type with register_post_type(). You can add this argument like this

$labels = array(
    //... add the labels as you need
   )
);

$args = array(
    'labels'             => $labels,
    //add other options as you need
    'rewrite'           => array('slug' => 'view-promotion')
);

register_post_type( 'promotion', $args );

}

EDIT:

You need some other identifier to differentiate between the page and your custom post type. Otherwise Wordpress won't be able to know whether you mean the view-promotion page or the custom post type.

Even something like this will work

...
'rewrite' => 'view-promotion/a',
...
5
  • thanks for the help. However, I am trying to have the view-promotion page to use the Page Template. Changing the slug would only still have wordpress to use custom post type template.
    – Noobie
    Dec 28 '14 at 8:14
  • @Noobie do you mean that view-promotion is a page that you have created?
    – sakibmoon
    Dec 28 '14 at 8:16
  • Yes. I am trying to have view-promotion page to pull content by using custom post name.
    – Noobie
    Dec 28 '14 at 8:17
  • @Noobie see my edit.
    – sakibmoon
    Dec 28 '14 at 8:29
  • thanks a bunch. It works when I set it to (view-promotion/). May I ask why putting it this way works?
    – Noobie
    Dec 28 '14 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.