query_posts
Avoid this function at all costs. The likely cause of your problem is queries not cleaning up after eachother. Your call to query_posts will have modified the main query ( wasting the original ), and messed up everything following it.
Instead use WP_Query
followed by wp_reset_postdata
$query = new WP_Query('cat=17&posts_per_page=1&meta_key=FeaturedOnHomepage&meta_value=yes');
if($query->have_posts()){
while ($query->have_posts()) {
$query->the_post();
?><a href="https://wordpress.stackexchange.com/questions/62645/<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php
}
wp_reset_postdata();
} else {
// you didn't put anything here either
}
You should format your code appropriately, too many , and don’t use the if(): endif; stuff, it’s cluttering up your code and preventing code editors from matching braces
Related Posts:
- WP_query parameters for date range
- greatest() function returns undefined property
- Call to a member function have_posts() on a non-object on normal loop
- Multiple instances of nivo slider plugin
- ACF: post query, hide duplicate values [closed]
- Render content of multiple pages and their descendants
- order posts by `meta_key`, Does not display posts that does not have `meta_key`
- How to display a number of posts based on a Advanced Custom Field (ACF)
- How can i listing current category and Featured Category post list?
- custom post type get_posts() function not work
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- how to repeat taxonomy in different places on wordpress
- Show all posts of all categories but excluding a category on custom blog page with pagination of my theme
- get post excerpt by query
- WP-Snap too slow (caused by WP_Query?)
- single.php fires more than once after clicking on any post to view with different post id each time
- WordPress plugin not eching popular posts
- Browser Cache causes ‘Orderby=rand’ to return the same posts
- ‘Active lotteries’ only custom query for woocommerce lottery plugin and elementor
- Specific way to allow WordPress users to view their current password? And edit it?
- Add Shortcode tag in Widget/Sidebar
- Basic function call on init failing
- echo statement displayed on front end
- Is it possible to remove subscription box from Jetpack stats page? [closed]
- In Woocommerce theme need to add custom external link [closed]
- How to create a post with next buttons
- Problem with isset and $_POST
- multiple language website navigation menu suggestion
- WooCommerce product and terms count [closed]
- Error checking when future updates are automatic
- http_response_timeout filter not working
- Create custom template in plugin and display it into post template section?
- Woocommerce Change The Price Of A Product Once Woocommerce Has Retreived It From Database
- Allowed memory size exhausted problem
- Getting taxonomy images to display on single-post with their terms
- plugin generated 751 characters of unexpected output during activation
- Where to populate custom terms in custom taxonomy in plugin?
- Get all woocommerce comments/reviews
- How can i force wp-admin to use 2-column dashboard layout? [closed]
- WordPress contact form 7 to show the form dropdown menus as like [closed]
- get meta value from database by post id
- Plugin function inside custom plugin
- Adding media upload button to User Profile page (following a tutorial)
- WP Google Fonts question [closed]
- First plugin, problem with get_pages
- wordpress content .php file in an iframe’s src in a wordpress post
- How to create a page with links to other pages that include image and excerpt?
- Flipping Book PHP Code? Any experience?
- Create WordPress posts from JSON array using plugin in admin
- Theme Custom Pages
- WordPress as template engine
- Meta Box by Rilwis, Load metabox on all page templates EXCEPT the homepage
- Undefined index: action plugin problem
- Insert Message before content of after title
- Custom url rewriting
- Cropping images from top center using Jetpack Photon
- Localizing methods for jQuery append prepend wrap parent
- Infinite scroll messing up nth:of-type
- How can I exclude a dynamic URL to show a popup created using ‘WordPress Popup’ plugin
- How do I find out which plugin is exceeding memory limits?
- How can I apply a WP filter on specific plugin version
- Taxonomy Drill-Down / Plugin Help – hierarchical queries within plugin?
- How to create Admin Notice from Plugin with argument? [duplicate]
- How to connect rating to individual comments?
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Edit / Change Jetpack Mobile Theme [closed]
- How to multiply a post to test internal search results?
- Looking for advice for a mail sending plugin
- query_post and wpdb returning different results
- How do I avoid having duplicate of plugin in trunk?
- Are links allowed in the Upgrade Notice section of a plugin’s readme.txt file?
- Use conditional logic for woocommerce variable product
- Use different single.php file based on condition
- Change the style of h1, h2, only in post entry
- wp-load.php redeclares classes
- How to customize a title by passing query string?
- How to create wordpress widget that is fixed position on the home page
- How do I rename a category in the menu bar only?
- Remove Advanced Custom Fields plugin for client?
- How to reset the plugins without deactivate the plugin
- plugins_url() works everywhere but wp_reqister_script()
- Better WP Security : dashboard doesn’t work any more
- Too many login attempts
- How to check if an email was sent from or originated from a specific plugin?
- Wooslider custom css
- Software to run on server checking outdated wordpress installations
- Where is this strange og:description coming from?
- Using Variable in WordPress Translate Functions
- How to change the wp_upload_dir() path in plugin
- how to connect the author profile with google webmaster tools in multiuser blog?
- Plugin getting Cannot modify header information errors
- Remove timthumb.php from my custom theme
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- Ajax Plugin Not Echoing Response
- How to add options to the plugin page?
- Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin
- iframe not showing in post (with “allow php in posts” plugin activated)
- Saving widget options from class method
- Odd /wp-admin/admin-ajax.php entries showing in Wassup
- how can I query all wordpress users of a blog