1

I have 2 post types (Doctor specialization, Doctor Profiles).i need to show the post type contents in 2 select boxes.

  • You have to query your post type content. If you don't know how then have a look here – Porosh Ahammed Nov 1 '17 at 8:55
1

Below Code will generate Select box of post type "resources" change this value as per your post type.

<select name="page_id" id="page_id" class="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
        <option value="">Select Resource Post</option>
            <?php
             global $post;
             $args = array( 'numberposts' => -1,'post_type'=>'resources');
             $posts = get_posts($args);
             foreach( $posts as $post ) : setup_postdata($post); ?>
            <option value="<? echo get_permalink($post->ID); ?>"><?php the_title(); ?></option>
            <?php endforeach; ?>
</select>

It works for me. thanks

  • @Vyus Projects : you can Upvote if it works for you. – megi Nov 2 '17 at 6:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.