In my Facebook group a user asked:

I am working on a site that is linked to motor sports. They have CPT's for Team, Car and Drivers. I was looking to create a template for the team then have a easy post to show the cars relating to that team, I could then also use the same set up to display the drivers of the specific cars. as to the ACF field type I am at the early planning stages so can incorporate any type of field to make it all easier.

This members-only tutorial provides the steps to set up Advanced Custom Fields' Relationship field so site owners can manually select cars that are related to or belong to a specific team and to output them on single team pages using Easy Posts component's posts layout in Oxygen.

when editing a "team" entry in the back end

"team" CPT entry page on the front end

Step 1

Create team and car Custom Post Types using a plugin like CPT UI.

Step 2

Add a new custom fields group named say, "Team Meta".

Add a relationship-type field named say, related_cars.

Set the field group to appear on team CPT entry edit screens.

Step 3

Add/edit Team entries and select 1 or more related cars where applicable.

Step 4

Create a Template for single Team entries.

Edit it with Oxygen.

Add a Section where you want to show related cars.

Add a Code Block inside.

PHP:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($37/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
  • I’m having some trouble with this. I simplified the code only output the names and permalink of a related field. But on every page where I use the code, there’s an issue in the footer (social icons are not right-aligned, for instance). Here’s a link: https://debruin.convertcraft.com/aaron-de-bruin-esq/

    <?php

    global $post;

    $practice_areas = get_field( 'legal_practice_areas' );

    if ( $practice_areas ) {

    foreach( $practice_areas as $post) {
    setup_postdata( $post ); ?>

    <a class='oxy-post-title' href='<?php the_permalink(); ?>'><?php the_title(); ?></a>

    <?php }

    wp_reset_postdata();
    }

    ?>

  • magnifiercross
    >
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
    %d bloggers like this: