WordPress.org

Forums

The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Get edit post link outside the loop (1 post)

  1. Jack
    Member
    Posted 3 years ago #

    On a page I'm showing all subpages at once, with this code, but somehow the post edit link is not working. It keeps on showing the edit link to the parent page and not one of the subpages:

    $paginaas = get_pages(array( 'child_of' => $post->ID, 'sort_order' => 'desc' ) );
    	$aantal = count($paginaas)-1;
    	$paginanummer = round($aantal / 2);
    	echo "<div class=\"fivecol\">";
    	foreach( $paginaas as $page ) {
    		$content = $page->post_content;
    		$getpostID = $page->ID;
    		if ( ! $content )
    			continue;
    		$postafbeelding = get_the_post_thumbnail($page->ID, 'postafbeelding');
    		if ( $aantal >= $paginanummer) {
    		?>
    
    		<div class="tekst">
    		<div class="edit"><a href="<?php echo get_edit_post_link($getpostID); ?>">edit</a></div>
    		<h2><?php echo $page->post_title; ?></h2>
    		<?php if ( has_post_thumbnail() ) { the_post_thumbnail('postafbeelding'); } ?>
    		<?php echo $postafbeelding; ?>
    		<p><?php echo $content; ?></p>
    		</div>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.