WordPress.org

Ready to get started?Download WordPress

Forums

Types - Custom Fields and Custom Post Types Management
[resolved] Add URL to child title on parent post page (5 posts)

  1. thaiso
    Member
    Posted 1 year ago #

    Hello,

    I would like to add a link that goes from the parent post page to the child post page.

    I so far have the following code which displays the title of the child post : `<?php $child_posts = types_child_posts('students');
    foreach ($child_posts as $child_post) {
    echo "'.$child_post->post_title.'";
    } ?>`

    I would like to turn this into a link to the post, is this possible??

    Thanks

    http://wordpress.org/extend/plugins/types/

  2. thaiso
    Member
    Posted 1 year ago #

    I got the below to work, probably not the best code in the world but does the job.

    How would do the same, add link, image and title for the Parent custom posts page on the Child page??

    $child_posts = types_child_posts('students');
    
            foreach ($child_posts as $child_post) {
    
            $var_i = get_the_post_thumbnail( $child_post->ID );
    	$var_l = post_permalink( $child_post->ID );
    	$var_t = $child_post->post_title;
    
                echo "<div style='float:left; text-align:center;width:300px;display:inline-block;padding-right:5px;'>";
                echo "<a href='".$var_l."'>".$var_i." </a>";
    			echo "<p><a href='".$var_l."'>".$var_t."</a></p></div>";
  3. mbigul
    Member
    Plugin Author

    Posted 1 year ago #

    Dear Thaiso,

    That is correct.

    [ Signature moderated. ]

  4. thaiso
    Member
    Posted 1 year ago #

    Hi,

    How would I go about placing the same: a link, thumbnail and post title of the parent post on the child post?

    Thanks

  5. mbigul
    Member
    Plugin Author

    Posted 1 year ago #

    Dear Thaiso,

    Please check this link http://codex.wordpress.org/Function_Reference/get_post_ancestors . Hope it will help you.

    Please open a new thread, if you still having any issues. Because this one is resolved.

    [ Signature moderated. ]

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic