Use wp_reset_postdata();
to restore the global $post variable of the main query loop after a secondary query loop using new WP_Query. It restores the $post variable to the current post in the main query.
call wp_reset_postdata();
after endwhile;
<?php while($org->have_posts()) : $org->the_post(); ?>
<option value="<?php echo $post->post_name; ?>"><?php the_title(); ?></option>
<?php endwhile;
// reset main query
wp_reset_postdata(); ?>
Related Posts:
- Parent Page and Breadcrumb URL’s for Custom Post Types Not Working
- Adding an extra parameter [string] to my posts’ permalink?
- One Custom Post Type two different Templates
- Metabox messes up permalink
- How to retrieve custom post type permalink in another cpt?
- Custom post type – permalink
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Display correctly using metabox.io
- Permalinks for custom post type
- Create Connection Between two post types
- How to have this permalink structure: post_type/postname/custom_inner_page
- pre_get_posts for custom page builder meta box
- Additional section in custom post type permalink
- Disable closing on metaboxes
- How to include term custom meta into the custom taxonomy term permalink structure
- Blog posts for custom post type only
- Path to custom post type
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- Show Custom Post Type meta boxes only on Page Edit
- Cannot save CPT meta box
- How to make custom taxonomy into drop down select in a custom metabox
- Adding Page Templates to post but it ignored it
- Permalinks: custom post type -> custom taxonomy -> post
- Custom post type archive pagination 404
- Create a Dropdown from Custom Post Type
- Translating custom post type metaboxes [closed]
- Adding a metabox on a CPT’s submenu page
- CPT’s with landing page instead of archive – Url Rewrite?
- How to change permalink to include custom post type
- Removing Custom Permalink Structure for Custom Post Type
- Custom post type, permalinks, taxonomies and blog posts
- Fixed values for same post translations
- Custom post type permalink tag 404
- How to Add multiple instance of meta box to custom post type
- Custom post type permalink returns 404
- Use the same date-based permalink structure for all post types
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- permalink /category/post-name with custom post type and taxonomy
- Using POST method in meta box, no results
- meta box on custom post type
- “Post name” permalink returns home page for custom posts
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- How to organize hierarchical structure in custom post type with taxonomy (like with categories)
- Make custom post types and pages place nice, re: rewrite
- Custom Post Fields at the beginning of a Custom Permalink
- Flush Rewrite Rules when new site is created on network
- Pretty URLs and custom post types
- Form action doesn’t work if slug isn’t same as custom post title
- How to make permalink structure %category%/%postname%/ work for custom post type?
- set permalink for CPT
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Lost of query parameter when using permalink
- Custom permalinks rules don’t match and lost of query var in the process
- Custom Post Type – Duplicate Page Slugs
- Checking if $_FILE isset for an array of file upload metaboxes
- Ordering values entered in Custom Taxonomies
- Listing custom terms in custom post meta
- Rewrite rule for Custom post type Monthly and Yearly archive
- Permalinks: custom structure for taxonomy – tags?
- Different results between permalink and query var search
- Custom Post Type & Meta Box – Displaying meta box information on front end?
- menu link to custom post_type?
- How can I move (or create another) publish button?
- Custom permalink with child taxonomy terms
- Wrap meta boxes & data handling for specific post types in classes?
- Custom post type Permalinks with hierarchical Taxonomies
- 404 in custom post type feed with mistake permalink
- Can custom fields be added without a meta box?
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Meta Box on Custom Post Type not saving
- Add a permalink variable onto custom post type URL after post name slug
- Custom “radio button meta box” not saving correctly
- Global custom meta box
- Sizing textarea field in custom metabox
- Moving meta boxes in admin
- Meta Data for Custom Post Type not saving
- Remove “show sharing buttons” metabox Jetpack from custom post type
- Add additional field to custom post_type
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- Remove permalink for custom post type
- Custom Post Meta from custom metaboxes is randomly being deleted
- Permalink misbehaving in Custom Post Types
- Check post on publish for blank title
- How to solve this custom post type goes to 404 page?
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- How to Create Template File for Parent Page of Custom Post Type
- How do you create %post_type%/%postname%/ permalink structure?
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Changed permalink structure of CPT – should I redirect?
- custom post type metaboxes not saving
- Add a custom meta box for client to order CPT posts how they want
- Save Multiple Metabox values
- How to query 2 custom post types that need to share a slug?
- I’m having trouble getting the permalink sample on my custom post type edit page to work
- How to change path for default WordPress blog posts?
- How to hyperlink content from archive page with custom post-type