Refer to the Codex page for setup_postdata()
:
Important: You must make use of the global $post variable to pass the post details into this function, otherwise functions like the_title() don’t work properly…
Also note that you can use WP_Query
to do these queries, rather than writing raw SQL.
Related Posts:
- modify all posts of a category to “no comments allowed”
- Deleting Custom Post type data using mySQL command
- wpdb custom post_type problem
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Insert post metadata for all posts in CPT at once if metadata no existent
- Convert simple SQL Query to WordPress query
- Why doesnt my tag page populate with this custom post type?
- Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]
- What does this PHP function code mean? [closed]
- How do I append multiple taxonomies to the URL?
- WP 3.1 – archive pages for custom content types possible now without a plugin?
- Admin Post Update Redirection to Posts Screen
- How to not allow custom roles to edit published custom post types?
- Assign Page Template Within A Custom Post Type
- How to override parent theme function through the child theme [closed]
- Single Page WordPress CSS and JS links
- [Plugin: Posts 2 Posts] Changing display order of connections
- Disable dragging of metaboxes in custom post types?
- Error after deleting Custom Post Type with a function (no trash used)
- How to delete all posts from a custom post type?
- Structure for projects and clients
- Custom Post Type Alerts
- Why is my custom loop not filtering correctly nor paginating?
- Custom post types with custom directories
- Saving repeated option values in a custom query
- Calculating Bayesian average for custom post type
- How to best delete orphan wp_postmeta
- How to customize admin posts based on the user who is logged in
- Custom Post Type | Fatal Error on register_post_type()
- How to post twitter like updates on wordpress
- How to get all `supports` attributes by post type?
- apply filters only to specific post listing without check the url parameters
- Dynamically add / duplicate custom meta in custom post types
- How can I create a custom meta box to add an mp4 video to a page?
- Custom post type menu missing after 3.0b2 -> 3.1.2 upgrade
- Group posts by custom post type
- Plugin: register custom post types, child ready and performance best practices
- convert custom query to wp_query
- Permalink structure by Post Meta value
- Define new user capability for custom post types?
- 2 Templates 1 custom post type according url
- changing meta value and meta key of price field
- How to handle paged param in post and custom-post-type?
- How to import a custom MySQL DB table into a WordPress custom post type
- Shortcode to display Staff post type based on Location post type and Specialty post type
- Function causing the loop display posting more (empty)
- Adding the_content() in custom template email
- How to add attributes to taxonomies that may be different from post to post?
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Migrating a taxonomy’s tags to the native category
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- How to sort posts in a custom post type by title in ascending order by default?
- $post not working working in AJAX plugin with custom post type
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Replace dynamically content in a custom database table when a custom post is created
- Navigate posts with different post type that are in the same categories
- Basic wpdb update question
- How to get the current category with custom posts
- WordPress Count posts within a custom post type
- Custom Post Types and Removing Slugs – should we do it?
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- Custom Content Type with No Page View
- Custom post type tags not showing in search
- Function to add custom HTML into head in custom post-type list page
- What is the best way to manage small blocks of content on my home page?
- One post auto attached to many another items
- How do I “trash” a custom post type post while logged in as Admin
- WP 3.1 custom post type permlinks
- Placing Admin Post Metaboxes in Tabs
- See if the email exists or not
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- What is my error trying to create a new table in the database?
- Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?
- Querying posts that don’t have a certain key value or don’t have the key
- wp delete duplicate entries of custom post types every 15 minutes
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Attempting to create custom “post” template, getting a 500 internal server error
- Update 2 wordpress tables at once
- Multiple WordPress Sites, Same Database but Filtered Content
- How to use costum database table for custom post type
- connect users to Custom post types
- Populate custom post type/custom fields from an external database
- Custom Pagination based on Custom Post Type
- Custom user roles
- One Post with different content, depending on a Page
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Custom Post Type
- Registering an optional custom post type from a plugin
- Shared Custom post type between WP network sites
- Query Distinct Taxonomies of Custom Post Type
- Custom metabox value not saving
- Cannot modify a registered custom post type rewrite slug
- Add Excerpt On Quicksand Plugin
- Select Menu for Custom post Type does not save
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Inserting two categories
- How to delete unnecessary custom post types in the UI
- Advise on Custom Taxonomies and Structure
- display posts, pages and custom post types from another wordpress site