Support » Fixing WordPress » Get edit post link outside the loop

  • 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>
  • The topic ‘Get edit post link outside the loop’ is closed to new replies.