New answers tagged

0

You can add meta tags using wp_head hook action from functions.php of the Themes files or create a custom plugin. Here you can check example. add_action('wp_head', 'fc_opengraph'); function fc_opengraph() { if ( is_single() || is_page() ) { $post_id = get_queried_object_id(); // get current post id $author_name = 'set your author name'; $...


0

There's no direct way of getting the post author's email from a post. You can get the email by using the author ID, which is present in standard WP_Post object. $post_author_id = intval( $post->post_author ); $post_author_email = get_the_author_meta('email', $post_author_id); Or if you just have the post ID $post_author_id = intval( get_post_field( '...


0

To obtain and get the author ID outside the loop: global $post; $author_id = $post->post_author; Then use get_the_author_meta('field_name', $author_id) remember if you are fetching posts id in loop and accessing author out side loop then it will only provide data of last post id in loop


0

Hopefully this wil help: $args= array( 'post_type' =>'any', 'post_status' => 'publish', 'order' => 'ASC', 'posts_per_page' => '-1' ); $posts = new WP_Query($args); $posts = $posts->posts; foreach($posts as $post) { switch ($post->post_type) { case 'page': // get the author's id through the post or ...


Top 50 recent answers are included