get post author id outside loop
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.
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.