0

I have a custom post type 'books' which I store different custom fields of information about books.

I want to use posts and link the posts I write (in categories such as news, or offers) to the books.

For example, when the user is viewing the book information page, I want to be able to display all the posts in news category related to that book.

I was able to do this using a custom field and assigning the book id to the news. But what if I have a news that's related to a lot of books?

Is there any way to file all the Custom Post titles to a taxonomy? What's the best way to do this?

0

Try Posts to Posts Plugin

This plugin allows you to create many-to-many relationships between posts of any type: post, page, custom etc. A few example use cases:

  • manually curated lists of related posts
  • post series
  • products connected to retailers
  • etc.

Additionally, you can create many-to-many relationships between posts and users. So, you could also implement:

  • favorite posts of users
  • multiple authors per post
  • etc.
0

Creating these links and displaying them on any desired page with a widget or shortcode can be easily done with a plugin called Sub Posts. It's not a free plugin, but it will do exactly what you're asking. You can find more information at www.subposts.com

0

In your functions.php file, you can register a new taxonomy and related with your custom post type, for example

create a custom post type: https://codex.wordpress.org/Function_Reference/register_post_type

register_post_type('books',
      array(
        'labels' => array(
          'name' => __('Books', 'sc'),
          'singular_name' => __('Book', 'sc')
        ),
        'public' => true,
        'has_archive' => true,
        'rewrite' => array('slug' => 'books'),
        'supports' => array('title', 'editor', 'author', 'thumbnail')
      )
    );

Create a custom taxonomy (similar to categories) https://codex.wordpress.org/Function_Reference/register_taxonomy

register_taxonomy(
      'gender',
      'books',// your custom post name
      array(
        'label' => __('Gender', 'sc'),
        'rewrite' => array( 'slug' => 'gender' ),
        'show_ui' => true,
        'public' => true,
        'show_in_quick_edit' => false,
        'meta_box_cb' => false,
        'show_in_menu'=>true,
        'show_in_nav_menus' => true,
        'query_var' => true,
      )
    );

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.