Support » Plugin: Toolset Types - Custom Post Types, Custom Fields and Taxonomies » Displaying custom fields from child pages that share the same parent.

  • I hope I explain this clearly, might get a little confusing…

    Some background; I’ve basically set up a page structure as follows

    Parent A -> Prod 1, Prod 3, Prod 4
    Parent B -> Prod 2, Prod 5, Prod 6

    And so on…

    On each Product page (child) I have a bunch of custom fields that are pretty straight forward. However, and this is where my query lies, I have a ‘product_thumbnail’ field where a user can upload an image that will be displayed throughout the site in a carousel of other ‘products’ which share the same ‘parent’ page (in the example above, on Prod 1 page, there would be a carousel of Prod 1, Prod 3 and Prod 4’s thumbnail).

    I know this is partly a WordPress question as well as a plugin-specific question but even if I were to gain some help around displaying the ‘product_thumbnail’ field for ALL entries I can probably find the answer to only displaying/filtering those with the same parent page some place else.

    Any help would be appreciated – let me know if I haven’t explained myself well enough!



Viewing 1 replies (of 1 total)
  • OK I worked it out.

    It is as follows for anyone who has a similar need to my own…

        // Get the page's children
        $children = get_pages("child_of=" . $post->ID);
        if (!empty($children)) { //check if there are any children pages.
        //If there are....
            foreach($children as $child) {
                // Get the meta value (product thumb) from the child page(s)
                $thumbs = get_post_meta($child->ID, 'wpcf-product-thumb', true); 
    			// Get the permalink for each child page....
    			$url = get_permalink($child->ID);
    			$productname = get_the_title($child->ID);
                // Wrap permalink around the image & display the image
                echo "<div style='text-align: center;width:228px;display:inline-block;padding-right:5px;'>";
                echo "<a href='".$url."'><img src='".$thumbs."' style='display: block;margin: 0 auto;'/></a>";
    			echo "<p><a href='".$url."'>".$productname."</a></p></div>";
    		//If there aren't any child pages...
        } else {
        	//Blank space
Viewing 1 replies (of 1 total)
  • The topic ‘Displaying custom fields from child pages that share the same parent.’ is closed to new replies.