Ecommerce Shopify WordPress Discussion

In wordpress how to get all pages by a specific author?

I need to get all pages(not posts) published by a specific author in wordpress, what is the php code to do that?
Assuming you have the ID it's possible to query using WP_Query object. If you don't have the ID you can find it also by email, or other means. Don't forget to reset the global $post variable pointer to the beginning of the loop using wp_reset_postdata() $username = "username"; $meail = ""; $user = get_user_by('login', $username); // $user = get_user_by('email', $email); $user_id = $user->ID; $args = array( 'post_type' => 'page', 'posts_per_page' => -1, // -1 to retrieve all pages 'author' => $user_id, ); $posts = new WP_Query($args); while ($posts->have_posts()) { $posts->the_post(); echo ('<h1>' . get_the_title() . '</h1>'); } wp_reset_postdata();

February 26, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.