Follow us on
  1. 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 ;

    https://prnt.sc/25cq7ec
    https://prnt.sc/25cq9r1

    Posted 1 year ago #

  2. Codestar
    Admin

    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 #
  3. Great! Thanks.

    It solved also how can show selected posts on the frontend ?

    Regards.

    Posted 1 year ago #

  4. Codestar
    Admin

    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 #