Wordpress Code & Research

Icon

All things about wordpress

Get page in wordpress

1- When you want to list all pages, you can use this function:

  <?php wp_list_pages( $args ); ?>

2- Get ID OF A PAGE BY SLUG PAGE

function get_ID_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
}

3 – Get page title by page ID

<?php $pageID = 86; $page = get_post($pageID); 
echo $page->post_title; ?>
Advertisements

Filed under: BASIC CODE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: