Support » Plugin: Custom Post View Generator » [Plugin: Custom Post View Generator] postmeta informations from other related custom post types

  • Resolved renfrei


    hi there. thanks for the nice plugin. i’ve set it up to display a list view of 3 different custom post types. example: crew members (picture, text, year, ..), cars (picture, text, …) and teams (crew member 1, crew member 2, car). every single list works perfect. but, if i try to build teams, there is a little problem. with custom fileds (field type=post object) i can build the team by choosing the 2 members and the car. after that i get a list with links, but how can i display the picture from the other custom post type (exmaple: picture from cars) in the list team? thanks for help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Marco Constancio


    I think I get what you want but it depends what exact fields you are using so this might no be the most correct answer.

    Most likely you will have to use a “custom html field” (Misc section) and append the field with the picture and showing as “Image(s) (WordPress Attachment)”. It possible that you might want to create an extra field in order to store some kind of info about the association, but again it depends on what fields that you are using, so I can only help more with more data because the plugin allow some variations on displaying data.

    Some additional Informations.

    Fields in List View «crew members»: (works as simple list)
    – crew_description = Text
    – crew_image = Image(s) (WordPress Attachment)

    Fields in List View «cars»: (works as simple list)
    – car_description = Text
    – car_image = Image(s) (WordPress Attachment)

    Fields in List View «teams»: (works as simple list)
    – driver = WordPress Post/Page ID
    – co-driver = WordPress Post/Page ID
    – car = WordPress Post/Page ID

    How can I display the chosen Image in «car_image» in my List «teams» in the HTML Template by selecting the teams car? The same for driver and co-driver. At the End, I need the Picture for the driver, co-driver and the car in my HTML to display one team; not the Links.

    Hope that helps!

    Plugin Author Marco Constancio


    Assuming each list is a custom post type, it is difficult to relate data from deferents custom post type without additional code.

    Given the way custom post types and my plugin work, you will have to create a fieldtype file in the fieldtype folder and select that new type on the Type dropdown in the list form.

    Create the file cpvg_car_img.php in the fieldtype folder and place the code below replacing “car_img” with the name of the car image id field (in your post you have just car) and medium and space with other image parameters if you want (check the file cpvg_image_wpattachment.php for more info):

    include_once "cpvg_image_wpattachment.php";
    class cpvg_car_img{
        public function adminProperties() {
    		return array('cpvg_car_img' => array('label'=>'Car Image'));
        public function processValue($value='NOT_SET',$output_options='',$additional_data) {
    		$cpvg_image_wpattachment = new cpvg_image_wpattachment();
    $post_data = get_post_meta($value,"car_img");
    		return $cpvg_image_wpattachment->processValue($post_data[0],array(null,"medium","space"),null);

    All you need to do is select Car Image type on the list field.

    NOTE: I posted this code to exemplify what you need to do, but If you plan relate more data from different post type or do more complex functions you might need learn to extract data from wordpress or get someone that knows how to do it.

    Yes, you can 😉

    Works perfect!
    Many thanks, that’s what I needed.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Custom Post View Generator] postmeta informations from other related custom post types’ is closed to new replies.