You need to call global $post
before using $post->ID
, or better, use get_the_ID()
instead.
Related Posts:
- How to return only one instance of each, from the entire loop
- Displaying terms based on loop posts?
- Redirect to another page using contact form 7? [closed]
- Split Content and Gallery
- AJAX with loop filtering categories
- How to return loop contents
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Return vs Echo Shortcode
- have_posts() return false but count says “3”
- as a shortcode within the loop?
- post__in – Placing content from a foreach loop inside of an array
- Get posts that matches specific terms of multiple custom taxonomies
- Exclude filter on front page
- Filtering posts by multiple taxonomies
- Using get_term() in functions.php results in Invalid taxonomy error
- How to use shortcode attribute in separate function
- Adding shortcode closing tag after a loop
- Filtering The Loop For Single Page and Blog Page
- Sort Posts By Category?
- What are the disadvantages of using global variable?
- Custom search form to display users only
- How can I modify the loop from a plugin without wiping out other filters?
- How to get an array of years from all of the search results, and use it to filter by year the paginated loop?
- Query posts if meta key starts with
- Query reset problem or flawed code to enable custom post type query
- Combining action and filter?
- I write simple wordpress loop for taxonomy.php file but don’t show result
- Filter the loop by categories using checkbox form
- Missing image in gallery shortcode in custom feed
- Shortcode with a foreach and arguments
- Output loop leveraged shortcode twice on one page
- Filter the_posts doesn’t work on search page
- Custom Loop Using Shortcode in Custom Page Template
- Shortcode in posts called by ajax is not working
- Problem with displaying HTML content after in_array [closed]
- Distribute Gallery Images Every nth in Loop
- Array ids post to function have_post
- Can’t access PHP array inside script localization from javascript
- Output meta into arrays
- How can I access specific posts brought back by query_posts?
- How to create a multidimensional array with multiple loops
- Display name of taxonomy once
- How to get user ID’s from multiple usernames?
- Make a loop to return x number of posts, but only if they have content or excerpt
- Loop through an array inside a class using foreach [closed]
- WordPress shortcode in content, output in sidebar?
- Query posts only with actual text content (not including shortcode or images)
- Filter existing hook using parameter and foreach loop
- Get most recent post for every term in a given taxonomy type
- CPT while loop not working
- display post tags on single.php inside loop
- relation OR instead of AND – Filtered term ID’s in loop
- How to put a block of code between [shortcode][/shortcode] in do_shortcode()?
- How to use this $tax_selection variable in this custom loop?
- Exclude posts based on an array
- Avoid WP_Query’s duplicate posts with taxonomies
- Add 2 values to post__not_in
- How can I pass additional params to a shortcode while in a loop?
- Loop order issue with Ajax filter
- Get a Post Loop based on Logged in User information into a Shortcode
- How to add pagination in Terms
- Use ACF Category Image for all Taxonomy Archive Views
- Add Search and Filter functionality to custom loop
- Reorder posts in a loop: have the posts by one particular author below the others
- pages shortcode filtering by category
- dispaly all hierarchical post types from a taxonomy
- Split Content and Gallery
- Query posts and display all dates in repeater field in chronological order
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- How to filter get previous post function by meta value DESC and post date DESC?
- WordPress redundant posts based on meta field
- Only seems to be displaying one child when there are supposed to be multiple
- Loop shows post 5 times in a query
- Attachment Metadata inside of Loop
- Remove posts_orderby filter then add it back in
- Creating a archive for taxonomy terms, not the term results
- Can’t print out returned value
- Buddypress Group Activity Loop Filter activity type [closed]
- Have multiple loops on a page appear after/between page content
- Using shortcode within shortcode with dynamic variable
- get_posts and wp_autop (remove filter)
- WordPress loop: Display if posts exist
- Help with add_filter(‘the_content’, ‘some_function’) and multiple matches
- How can I access ‘key’ and ‘value’ from an array in a for loop?
- How wp maps urls into files
- Applying a filter to multiple loops for days ago
- Order Categories by Character Count
- How to get files from loop for zip
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Why we use if with while loop?
- Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?
- 3 Posts in Loop, Show Stickies First
- Loop within a loop (Again) for template
- Ajax Button to load more Posts into a timeline
- Get post-meta value of all custom-posts – lowest to highest year-count?
- Show related products by attribute based and certain conditions
- Is it possible to include the add_filter() function within a shortcode function
- Having issue with WordPress loop