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
- How to echo the value of an array element using a function via a shortcode
- Wp-query Order By problem
- issue with if/elseif in_array inside foreach loop display only one post
- How to parse a shortcode within a shortcode?
- Variables not showing in short code
- Woocommerce checkout field
- 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
- Genesis Framework: How to exclude a specific author from archive custom loop
- 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()
- How to create shortcode with html and php content?
- Tracking the number of shortcodes for a list?
- Need a method to prevent WP from adding in between my shortcodes
- Load scripts for do_shortcode( ‘ [ my_shortcode ] ‘ )
- Get term slug by term id and then explode it
- posts within custom post type all share the same content in the front-end
- Shortcode question
- Using functions.php to include code that’s processed inline
- Can I include a custom PHP function in a WordPress function?
- How to create a shortcode out of a php function
- Shortcode to get featured image of specific id post
- Modify shortcode to work with custom post types
- shorthand syntax for custom fields
- Breaking up multiple words and inserting an image after first word
- Shortcode of a function
- show all the posts thumbnails
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- Simplest Way to Build Custom Archives Page?
- Problem with shortcode inside a shortcode
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Need help making a short code work
- Using One Function To Create Two Different Shortcodes
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- Display a list of random terms from custom taxonomy with shortcode
- the_date() and the_time() functions display actual date an time instead of published date and time
- 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
- Pagination not working – FrontPage
- Customizing the wp_video_shortcode output with add_filter
- page shows short code not output
- Probleme shortcode with list author
- Function to function shortcode help [closed]
- Last updated posts shortcode in functions.php
- I want to display the sku in the product pages of my EDD website
- How set a while with a function
- 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?
- Pass post ID from archive template to functions file
- Prevent function from triggering on current page
- use add_action in a shortcode (gravity form – WordPress)
- How to use `foreach()` in ajax call
- Shortcode displaying outside the div [duplicate]
- Shortcode Initialization in a Custom Theme
- Shortcode with pagination advancing multiple queries
- Show users last read posts for each user?
- Get shortcode attribute value to another function
- How to retrieve image IDs from shortcode content?
- Display list of pages that contain a certain string within the slug
- Hide disclaimer from summary excerpts
- HowTo: Add wrapper to columns shortcode?
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Function not receiving string from shortcode
- How To Show Shortcodes In WordPress Custom Fields?
- Shortcode Function – Can’t get anything else to return after running shortcode within shortcode
- Only seems to be displaying one child when there are supposed to be multiple
- Custom shortcode with do_shortcode and substr
- Shortcode to eliminate and replace with
- Can I use a function to return HTML and the result of another function?
- Integrate WP Tiles into existing loop (index.php) and theme
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Expanding a function to call a plugin or show a link
- Check if excerpt is empty at loop-portfolio
- Function to get the name in database table from the comma separated string
- Trying to the deduce shortcode from a function
- How to display data from custom fields in my custom shortcode?
- Modify function Shortcode_atts
- Pull random comment from specific post, display on homepage with shortcode
- Set thumbnail from URL, by grabbing image in functions.php
- Shortcode to output get_header not working
- restrict access to specific urls on a specific period of time
- using enqueue_script in a shortcode isn’t working
- Run function from parent on child site
- Way of getting queried loop before the query with a filter hook?
- Gallery Shortcode Function Help
- Add title & subtitle to shortcodes
- Post variables not displaying correctly in custom function
- Echo custom field value in shortcode function
- Shortcode Variations?