How to get page id by slug wordpress theme

How to get page id by slug wordpress theme

WordPress tutorial for, How to get page id by slug wordpress theme. First find the page id using page title or page page slug.  we given sample code here.

How to get page id by slug wordpress theme

For post title use following code:

<?php
$page = get_page_by_title( 'About' );
wp_list_pages( 'exclude=' . $page->ID );
?>

For post slug use following code:

 $page = get_page_by_path( 'your-page-slug'
echo $page->ID;

Now List the child page by post slug

if ( $page = get_page_by_path( 'your-page-slug' ) ){
  wp_list_pages( 'orderby=name&depth=1&order=DESC&show_count=0&child_of=' .$page->ID . '&title_li=' );
}

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

3 thoughts on “How to get page id by slug wordpress theme”

  1. I’m really impressed with your writing skills and also with the layout on your weblog.

    Is this a paid theme or did you modify it yourself?
    Either way keep up the nice quality writing, it’s rare
    to see a nice blog like this one these days.

  2. It’s in point of fact a great and helpful piece of
    information. I am satisfied that you just shared this useful information
    with us. Please keep us informed like this. Thank you
    for sharing.

Leave a Reply

Your email address will not be published.