How to pass page as an argument like post in WordPress?
-
10-05-2021 - |
Question
I am using this code to pass arguments in posts:
$args_automobile_just_launched_bike = array(
'posts_per_page' => 3,
'post_type' => 'post',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'wpcf-new-launch-bikes',
'value' => '1',
),
),
);
This is the format of getting posts dynamically.
How can I do the same for Page?
Solution
Pages are posts, you just need to change the post_type
to page
:
$args_automobile_just_launched_bike = array(
'posts_per_page' => 3,
'post_type' => 'page',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'wpcf-new-launch-bikes',
'value' => '1',
),
),
);
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange