You really shouldn’t use query_posts()
for anything other than the main loop of that page and use either WP_Query()
or get_posts()
, try this:
$my_query = new WP_Query(
array(
'category_name' => 'interesting_sites',
'posts_per_page' => 3,
'orderby' => 'rand'
)
);
while ($my_query->have_posts()){
$my_query->the_post();
?>
<div <?php post_class(); ?>>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
</div>
<?php
}
wp_reset_postdata();
Related Posts:
- Escaping a shortcode so it displays as-is [duplicate]
- About redundant code when I use shortcode to output the HTML from a variable
- WordPress do_shortcode first iteration
- add php shortcode in return function
- how to show last 5 images from the one post gallery
- Shortcodes in Options Panel textareas
- Display post_meta in Shortcode
- Loop output for custom plugin [solution found]
- Shortcode Attribute
- Gallery Shortcode: using size=”full” doesn’t call the actual thumbnail image size
- Can’t get default values to work with custom shortcode
- How to attach sidebar to shortcode’s output?
- If do_shortcode is blank, return some message
- Is it possible to change a shortcode parameter based on a media query?
- How to not show shortcode contents if cart is empty?
- Shortcode templates
- Add a short code to a plugin
- style css to header for shortcodes
- Add JavaScript in footer if shortcode used in page [duplicate]
- Can not get shortcode content in function
- Is there a way I can return terms by name using a shortcode?
- How wp maps urls into files
- WordPress Shortcode loads at the top
- Shortcode Output Always Before Content [duplicate]
- woocommerce Product shortcode create [closed]
- How to Convert Shortcode into a link?
- Question about do_shortcode
- Shortcode append to the the_content()
- A number appears inside a div called wpb_wrapper, when I use a custom shortcode
- Enclose article’s body with default shortcode
- How create a shortcode with html
- Adding shortcode [closed]
- do_shortcode autommatic content generation
- Previous/Next with the same category
- I’ve broken the short code for Contact Form 7!
- echo a shortcode in a shortcode code?
- wp_register_script and wp_register_style when shortcode is used
- Create plugin/function to catch XML-data via Shortcode
- Applying if (get_post_meta) to new shortcode
- Why My slider shortcode display above header
- How i make a shortcode from this code
- What does this shortcode do?
- Shortcode Attributes – post__not_in array
- IFrame Shortcode plugin – issue
- Does anyone recognize shortcode ig_special_heading?
- How to write a query-function as a query-shortcode?
- Help with Shortcode Functionality
- Add widget/shortcode to sidebar OUTSIDE of the theme
- Shortcode Site include in a other
- How to scroll to a shortcode-generated anchor
- add post type pram to wp shortcode
- How to call shortcode on button click
- How can you alter the name of attributes in a shortcode?
- How do grab the main loop, with conditions, and output via shortcodes
- Enclosing shortcodes create line breaks
- Insert shortcode in widget area
- php code to shortcode [duplicate]
- Add the results of a custom query into a do_shortcode
- Why is my ajax live search not working when i use a shortcode to call it?
- Wpautop stops working after get_the_excerpt
- Wrapping a function in html tag and return?
- Using $variable in shortcode
- How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes
- Shortcode leads to white screen [closed]
- Shortcode content is empty [closed]
- Shortcode with foreach
- How to stop an image link continuing to link adjacent text from a shortcode?
- Shortcode conversion to hrml when post is published
- Shotcode error on functions
- Shortcode for displaying the user’s first name?
- Creating mixture of shortcodes to use in the visual/text editor
- create shortcodes for posts
- Can I prevent wordpress adding and tags to autoembeds
- Shortcode – Display inline icon before text [closed]
- How Do I create a shortcode to dispaly a go to top button on any page or post
- Create a shortcode to display the “the_content ()” in my post [closed]
- How do write this type shortcode? [closed]
- Good example of a short code +4346? [closed]
- How to remove https:// from shortcode generated url
- WordPress functions.php shortcode is not working [closed]
- My first WordPress shortcode just returning []
- How to enable on custom shortcodes
- Nested ShortCode works inside the_content, but not outside of it
- WordPress shortcode select option not working [closed]
- I have the query code but not the shortcode
- Hook into existing shortcodes to manipulate the attributes?
- Show realtime Amazon price without API using shortcode
- wordpress how to sort posts on custom data with plug-in “Search & Filter”
- How can I hide the ACF shortcode when empty
- filter custom field with checkboxes and show it with one shortcode
- Identifying first and last instance of shortcode in post
- How to reuse php templates as shortcodes?
- Executing a shortcode at the top of PAGE template?
- Shortcode attributes from meta query variables
- How to pass text input data to shortcode
- 3 shortcodes 2 won’t render [closed]
- Using variable as shortcode parameter
- How to handle Ajax Calls, when using same shortcodes (with different parameters, e.g. ‘post-type’)?
- Display a block conditionally based on user input button
- Free Add to Cart Button on WooCommerce with Elementor – No Premium [closed]