WordPress.org

Ready to get started?Download WordPress

Forums

get_pages by slug (2 posts)

  1. baszer
    Member
    Posted 1 year ago #

    Hello,

    I want to get certain pages, I can do this by the code below, but is it also possible to do this by a slug? So when I delete the page I do not have to modify the code?

    <?php
    	$mypages = get_pages( array( 'include' => '220', 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
    
    	foreach( $mypages as $page ) {
    		$content = $page->post_content;
    		if ( ! $content ) // Check for empty page
    			continue;
    
    		$content = apply_filters( 'the_content', $content );
    	?>
    		<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
    		<div class="entry"><?php echo $content; ?></div>
    	<?php
    	}
    ?>
  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic