WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
List of related posts in main post (2 posts)

  1. miketurco
    Member
    Posted 1 year ago #

    Example is an owner/pet database. There are two post types: owner and pet. Each owner can have several pets. Is there a way to dispaly all of the names of an owners pets on the owners page, with a link to the pets page? I don't know much about php, but if there's some sort of example you can point out, I'll do my best to piece things together. Thanks!

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    Exactly how you do this depends on how you have defined your relation fields. Let's say for example that you have a repeatable relation field named "pets" that's used by the "owners" post-type. Your code inside single-owners.php might look something like this:

    <?php
    
    $pets = get_custom_field('pets:get_post');
    foreach($pets as $p) {
        print '<a href="'. print $p['permalink']; .'">'. print $p['pet_name'] . '</a><br />';
    }
    
    ?>

    The above example assumes that each pet has a custom field named "pet_name". If the pet's name is stored as the post-title, then you'd print $p['post_title'] instead.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic