wp_reset_query()
will reset the query to the original query WordPress did on this page. So if you somewhere called query_posts()
, it will not reset back to that query, but to the “main” query.
You probably want to use wp_reset_postdata()
, which resets the $post
variable to the current post in $wp_query
.
The best thing is to not overwrite the global $post
variable in your function. All WordPress functions have variants that accept a post object, so there should be no need to use the global variable there.
Related Posts:
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- What is the difference between front-page.php and home.php? [duplicate]
- Can a theme be built in React?
- Any alternate TinyMCE4 themes / subthemes?
- Strict Standards Error bootstrap navwalker
- How to alter the text of the post “Excerpt” box label in WordPress post editor?
- How can you develop on a live WordPress installation that is using W3 Total Cache? [closed]
- How to Auto Approve Comments on a Specific Page?
- How to deploy a new theme/theme options from staging to production site
- How do you enqueue script tags for ReactDOM in WordPress’ functions.php?
- How do I get gallery thumbnail URL and change the default thumbnail size?
- Select menu on browser resize
- Hard-coded Audio Player
- How to display admin bar when using WP_USE_THEMES = false?
- Responsive class to all the images in the content
- WordPress Errors in generated by theme check plugin [closed]
- Upgrading a custom theme through the Dashboard
- How can I customize wp_footer, where is the code that controls what this function does?
- More than one meta field in a single meta box?
- how can I remove the sidebar from my wp homepage [closed]
- How to develop child theme for thesis
- using jQuery Cycle by Malsup with WordPress Page and Gallery
- Why is the post type on the search result page random?
- How to add infinite scroll?
- How can I have a page on a site that isn’t a ‘Page’ in the WordPress sense?
- get_option in header.php not returning value from customizer
- What happens to child theme if I change to new version of parent theme?
- Show notice just below the search form on the themes page
- Save Widget State Between Theme Swaps?
- How do I build a post_thumbnail based archive? [closed]
- Single translation for many locales
- Display theme layouts [closed]
- Is accessing theme and using customizer GPL distribution?
- WordPress 500 Internal server error when activating custom theme [closed]
- How do i place same widgets multiple time by default on theme activation?
- Getting php_network_getaddress error : No such host is known?
- Combining CSS files into a single cached one
- How to set a page as homepage in stead of the newspages?
- WordPress Theme Validator?
- Get the amount of posts on a given page
- Wpautop in wp_editor not working
- Comment status shows ‘closed’ in db, but it shows ‘open’ when i echo it
- I used single quote to design HTML of my WordPress blog. Now site redirects to index.php everytime than page.php or single.php
- Is there any way to register custom background images like header images?
- html5-reset theme does not show the image [closed]
- WordPress HTML5 Gallery Support – Convert HTML4 -> HTML5
- Issue On Displaying Pages with Post Name Permalink
- How to make javascript work on theme options page
- Second menu has the first menu ID
- Contact Form Security
- Where do you add code in custom fuctions so it works on a specific page?
- WordPress: Allowed Memory Size Exhausted – After Moving from Dev to Live [closed]
- What exactly is “wordpress theming”? [closed]
- Present Color Schemes to Clients
- GrandParent ,Parent, Child issue
- Unable to add widgets to sidebars in custom theme
- View list of all attachments on site
- How do I display a greyed out next_post_link when there is no next post
- What is the difference between Twenty eleven & roots framework?
- Dynamically Populating Image/Excerpt/LInks from Pages in WordPress
- If I remove Category base from my URLs, how difficult will rollback be?
- Woocommerce AJAX filters option loading spiner – problem on mobile device
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- How to Modify WP_Includes/blocks/latest_posts.php
- Adding popup support to the theme
- How do I change the color of individual page titles in WordPress?
- Page For Specific Posts
- How toprint informations in footer
- How to implement pagination in category.php template
- How to reduce the vertical space above and below a ul list uniformly with one command?
- How can I show a custom WordPress menu anywhere I want on my website?
- WordPress Menu item > Sub menu Class update
- How can I use a different template file for the blog index’s paginated pages?
- How to know and change the machine name of a menu?
- How to customize the colors within a stylesheet using a WordPress setting
- How does mediaelement.js work in WordPress?
- Images use & location, on new wordpress theme
- On wordpress, how do i require specific dimensions from user uploads only
- how to create export / import theme options in wordpress without plugin
- WordPress Theme Developments – Start from another theme
- Access meta box checked value in another file
- Slider should be display in home template [closed]
- WordPress Customization API overwrite LESS variable
- Dynamic meta description
- How to Remove Sidebar when get_sidebar() is not get called in page?
- How does offset works on pagination? (get_results)
- Plugin or script to apply updated media settings to all featured images
- Header links also appearing in the footer
- Extending arrays in parent theme without completely overriding the files
- WordPress Subpages Fancybox Trouble
- Toolbox theme using printif statement – help needed understanding code block
- Search Results not displaying for multiple word search
- How to Create a Multi Purpose Theme?
- WordPress does not know the parametrs i sent to admin post
- customize functionality of share buttons under each blog post [closed]
- Custom Single Page Portfolio Theme [closed]
- WordPress search field won’t get wider