First, need to lose query_posts()
– it should never be used for secondary loops.
Try something like this:
$posts = get_posts( array(
'cat' => $category->term_id,
'numberposts' => 3,
));
foreach( $posts as $post ) {
$listing_code .= get_permalink( $post->ID ); //or whatever
}
Related Posts:
- Function to show only first instance of shortcode
- Custom Shortcode, functions PHP WP_Query loop
- How do grab the main loop, with conditions, and output via shortcodes
- Creating mixture of shortcodes to use in the visual/text editor
- Solution to render Shortcodes in Admin Editor
- Show modified time if post is actually modified
- Enabling shortcodes for custom fields
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- how to create shortcode in wordpress
- Display random text from a file with the WP built-in AJAX API
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- WordPress – thumbnail image from youtube (function and loop)
- Problem with extract() with custom shortcode
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Adding body class when post contains a specific shortcode
- A snippet after every image
- Creating loop within functions.php
- Display WooCommerce subscriptions for user [closed]
- How to use max and min values of custom fields
- creating shortcode to pull json array
- Filtering posts by category name based on page’s slug
- Pass Shortcode Attribute to footer Script
- Detect Safari desktop browser and include the detection in a shortcode
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- 2 Loops, Only Displaying 1 Loop in Both Loops
- Display gallery on top before content
- List child pages of specific page using shortcode
- WordPress shortcode attributes for database SELECT?
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Having a Function Inside of the Loop
- Getting different functions data while using while loop in wordpress
- Create a new query in function.php to filter blog posts
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- Setting youtube size in functions.php
- Default Custom Field Value Automatically Update
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Add button to kitchen sink toggle
- Excerpts are not displayed by a shortcode on category pages
- Why doesn’t is_page(id) work in functions.php?
- shortcode help require
- Optimizing a WordPress site
- wp_nonce_field is breaking form for reasons unknown
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- While loop with an exception after a count is reached
- Using multiple line variable inside a function?
- Echoing function into WordPress NextGen gallery
- How do I pull excerpts from pages?
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- How to include any template using Shortcode fuction?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- Problem with calling custom function in a foreach loop
- Need to convert image url to a Base_64 data url with wordpress function..
- dynamic site link for future migration in echo do_shortcode()
- Need a method to prevent WP from adding in between my shortcodes
- Get term slug by term id and then explode it
- Shortcode question
- Using functions.php to include code that’s processed inline
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- show all the posts thumbnails
- Simplest Way to Build Custom Archives Page?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Load templates, pass arguments, and render output from functions.php
- How to add if statement on WordPress shortcode output
- Passing function arguments via a shortcode
- Customizing the wp_video_shortcode output with add_filter
- Probleme shortcode with list author
- Shortcode to output category description by passing ID
- Help using ShortCodes to style whole chunks of the post
- Shortcode to insert default text and change one word throughout it?
- How to use `foreach()` in ajax call
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Hide disclaimer from summary excerpts
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Function not receiving string from shortcode
- Only seems to be displaying one child when there are supposed to be multiple
- Shortcode to eliminate and replace with
- Integrate WP Tiles into existing loop (index.php) and theme
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- using enqueue_script in a shortcode isn’t working
- Gallery Shortcode Function Help
- Echo custom field value in shortcode function
- Shortcodes not outputting in correct divs
- how to handle multiple forloop?
- How to write a query-function as a query-shortcode?
- PHP error in shortcode [closed]
- Update post meta with wp cron