-
Hi team!
I want to list all posts in select, how can i do ? Actually i did but selectbox is disappear.
Here is my codes ;
Posted 1 year ago # -
Hi,
There is missing "options" parameter. You must use like this:
// use like this: 'options' => 'posts', 'query_args' => array( 'posts_per_page' => -1, // show all posts (if needed) ), // btw, post_type usage example: 'options' => 'posts', 'query_args' => array( 'post_type' => 'portfolio', // generally we use this for custom post type 'posts_per_page' => -1, // show all posts (if needed) ),
CopyCopied!Regards, Codestar
Posted 1 year ago # -
Great! Thanks.
It solved also how can show selected posts on the frontend ?
Regards.
Posted 1 year ago # -
Hi,
You should take a look: https://developer.wordpress.org/reference/classes/wp_query/
For eg:
$args = array( 'post_type' => 'post', 'post__in' => $selected_posts_ids, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); echo get_the_title(); } } wp_reset_postdata();
CopyCopied!Regards, Codestar
Posted 1 year ago #