• Hi, gurus.

    I’m currently working on a search page that searches all the related posts from custom post types (Projects, News, Customer Service) I’ve created. When searching is successful, I’d like to output them like the following:

    ==

    Projects:
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ullamcorper elit at ex rutrum dignissim. Proin posuere ante ut aliquet sollicitudin. Suspendisse scelerisque libero sem […]

    Projects:
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ullamcorper elit at ex rutrum dignissim. Proin posuere ante ut aliquet sollicitudin. Suspendisse scelerisque libero sem […]

    Customer Service:
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ullamcorper elit at ex rutrum dignissim. Proin posuere ante ut aliquet sollicitudin. Suspendisse scelerisque libero sem […]

    News:
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ullamcorper elit at ex rutrum dignissim. Proin posuere ante ut aliquet sollicitudin. Suspendisse scelerisque libero sem […]

    ==

    Yup. Very simple as you see.

    The problem I’m having now is ‘how to get the name of custom post type that a post belongs to’ such as Projects, News, and Customer Service. I think I should pass a ID of the current post as a parameter to get its post type information but I don’t know which one. Is there a function that does the job for me?

    I will be digging WP codex deeper while waiting for wise answers.

    Thanks!

    • This topic was modified 8 years, 6 months ago by pluus.
    • This topic was modified 8 years, 6 months ago by pluus.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Get the post type name while looping’ is closed to new replies.