How to get page title with the page ID?
Try with this: <?php echo get_the_title( $ID ); ?>
Try with this: <?php echo get_the_title( $ID ); ?>
I just had to do this in one of my themes… Since you don’t have access to the $item variable at that stage of the Walker, you would want to store your current item in a more global scope at the moment you do have access to it. The following code will make more sense… … Read more
The simplest and most straightforward way to get the post author ID outside the loop, if you know the post ID, is to use the WordPress core function get_post_field(). $post_author_id = get_post_field( ‘post_author’, $post_id ); If you do not yet know the post ID of the page you are on, then since WP 3.1 the … Read more
The easiest way would be using get_post_field(): $post_author_id = get_post_field( ‘post_author’, $post_id ); For more details on this issue: have a look at this StackOverflow answer.
Use get_page_by_path($page_path): $page = get_page_by_path( ‘about’ ); echo get_the_title( $page ); This will return a regular post object. Documentation: https://developer.wordpress.org/reference/functions/get_page_by_path/ https://developer.wordpress.org/reference/functions/get_the_title/
Try global $post; echo $post->ID; or (I don’t know the difference) global $wp_query; echo $wp_query->post->ID;
Use the page_for_posts option: <?php $page_for_posts = get_option( ‘page_for_posts’ ); ?> This will return the ID of the Page assigned to display the Blog Posts Index.