• Hi there,

    I was wondering if there was a plugin or perhaps code to add to the functions file that can do the following:

    – So I would create a custom post type, for example: Author
    – Then I’d create a different post type for example: Book

    For the page, adding a book in the back-end, I’d like to create a drop down, displaying the custom post types of Author..

    So the ID would be saved of that custom-post-type..

    I’ve done some searching on google but didn’t come up with anything useful, so I thought i’d check here! Any help would be much appreciated!

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not sure I fully understand what you want here. You are creating a “Book” post and you want to be able to select a particular “Author” post to be associated with the “Book” post? The various Author posts are listed in a dropdown?

    If this is correct, you will need to add a metabox to the edit form that displays the dropdown. You will populate the dropdown by making a new WP_Query just as you would for any other post, but in the loop, instead of outputting title and excerpt, you would be outputting <option> tags of the dropdown with the author’s name as label.

    For more on metaboxes, see https://make.www.ads-software.com/docs/plugin-developer-handbook/8-metadata/creating-custom-meta-boxes/

    You can see there is more to this than some quickie code that I could provide. I doubt there is a plugin for this sort of thing, but it’s worth some searching to be sure, since it would save you a lot of custom coding.

    Hi @benji007
    I think you can use this plugin to make relations between post types
    https://scribu.net/wordpress/posts-to-posts/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying a dropdown of a custom post-type in another custom post-type or post?’ is closed to new replies.