• Resolved theApe

    (@theape)


    This is a bit of a strange one, I’m getting a 502 when removing a close and open php tag in the loop. I can’t see how these make the page work or cause the error when being removed.

    This works…
    See: ?><?php line 10

    endwhile;
    	
    	$prevLink = get_previous_post_link();
    	$nextLink = get_next_post_link();
    
    	if ($prevLink != '' || $nextLink != '') { 
    		echo '<div class="adjacent-entry-pagination pagination">';
    		echo '<div class="pagination-previous alignleft">' . $prevLink . '</div>';
    		echo '<div class="pagination-next alignright">' . $nextLink . '</div></div>'; 
    	} ?><?php
    
    else :

    This throws up a 502…
    ?><?php removed from line 10

    endwhile;
    	
    	$prevLink = get_previous_post_link();
    	$nextLink = get_next_post_link();
    
    	if ($prevLink != '' || $nextLink != '') { 
    		echo '<div class="adjacent-entry-pagination pagination">';
    		echo '<div class="pagination-previous alignleft">' . $prevLink . '</div>';
    		echo '<div class="pagination-next alignright">' . $nextLink . '</div></div>'; 
    	} 
    
    else :

    Any insight would be appreciated. It’s not a big deal to leave the ?><?php in, but I’m just a bit concerned there’s a bigger problem going on with my code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter theApe

    (@theape)

    I’m still stumped, but I ended up going with this in the end.

    endwhile;
    
    	$prevLink = get_previous_post_link();
    	$nextLink = get_next_post_link();
    	$output = '<div class="adjacent-entry-pagination pagination"><div class="pagination-previous alignleft">' . $prevLink . '</div><div class="pagination-next alignright">' . $nextLink . '</div></div>';
    
    	if ($prevLink != '' || $nextLink != '') :
    	
    	 echo $output;
    	
    	endif;
    
    else :
    Dion

    (@diondesigns)

    You can’t mix braces with the endif/endwhile/endforeach junk. Stick with one or the other for all your code…preferably braces since it’s the correct syntax in modern coding.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘502 Bad Gateway when removing close open php tags’ is closed to new replies.