Your query variable country
is not defined, its not part of the standard query_vars
set by WordPress, where as both monthnum
and year
are and that’s why they work and the former does not.
So you need to add your query variable into the mix, try the following;
function new_query_var() {
global $wp;
$wp->add_query_var('country');
}
add_filter('init', 'new_query_var');
Also, it appears that your foreach
is checking for the existing of this query variable and hence since its not set (e.g. isset
) then it fails the conditional check.
Related Posts:
- Creating search form for custom database table
- Search through custom post type and custom fields takes 5 minutes
- Customise search form in the Widget
- Comment filtering (search)
- Combine multiple words in custom meta search query
- Custom search page and search by title, content and tag
- Search a post using the date it was posted
- Setting custom search engine indexing for a “dynamic WordPress page” with htaccess
- Custom URL going to 404
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- Hi, I wanted to make custom search with multiple fields
- Steps for custom data retrieval
- Custom search to display results within same page
- Search widget will search everything in the site, how to limit to only search gallery name
- How to hook up search results page to a back-end page?
- Admin search post meta
- Add a searchbox to the body of a page
- Custom Search on Custom Page while preserving the main search function
- Custom Loop Query For Search Page
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to create custom search page
- Custom Same Page Search
- How to Add Additional Search Button?
- How to Clear Empty Search values?
- WP Search Form Query: Add Author’s posts into search query
- WordPress search on a custom table
- Adding overlay search to wordpress using add action/filter
- Allow WP users to sort search result on a videos site
- WP_User_Query Search Multiple Keywords from a Multi-Select Field?
- Custom dropdown search form that allows users to select option B based from Option 1
- Custom search results
- WordPress custom search – pagination
- Creating a search with tag variable also added for more detailed results
- What shortcode should I use for
- Two searchforms with different categories/posts per page
- Search a meta field for a value in all posts
- Custom search by several options send on form not works
- Search results load individual post in slide out div
- Custom Search Results Page
- WordPress Search on Multiple wp sites
- Create a custom search for Estate Agency WordPress site
- How can I make a search term redirect to a page
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Show total sales for each products on search results page Woocommerce
- Custom Search on media files PDF images pages posts
- Any post install tips after installing WordPress 3.0.1?
- Version Control: Entire site or just pieces?
- Getting a stack trace when an error occurs?
- Multiple WordPress sites with docker
- .maintenance and maintenance.php also in multisite install?
- how to redirect to a custom password retrieval page
- Is there a plugin to make attaching images easier?
- Maintaining synced staging/production WP sites
- WordPress Multi Site Best Practice
- Sub posts and non unique post_name
- How to let a single post have its own domain name
- page_template toggle between 2 templates + 2 permalinks for same post
- How to instantly delete posts/pages permanently?
- How to re-arrange media uploaded using : media_handle_upload() as per year / month
- How could we customize the all posts page in the admin panel?
- How do I perform a “get” call to an external API, and then display the JSON results on a page in my WordPress site?
- How to build a child theme from a react-based parent theme?
- Adding Pagination on a Custom Author Page
- How can I get the page url slug when ‘post_name’ returns an id?
- Woocommerce Product page edit
- Convert an theme options page to use in customize.php also?
- The best way to write an FAQ page?
- Get Value from Column in Plugin Table [closed]
- Display User ID instead of Name or Username
- Bind JS event to WordPress control customizer
- Get rid of title from static front page
- Make custom page look exactly as homepage
- $wpdb->insert running multiple times?
- OrderBy multiple custom meta fields
- Track usernames with piwik [closed]
- Woocommerce – Print Product’s Custom Field In Email
- WordPress broken after changing URL
- Display posts by combining multiple meta key
- How to make the Pages in WordPress Customized?
- Custom “wp_login.php?action=lostpassword” and reset password
- Custom theme – how to link the image without posting it
- wp_enqueue_script JS code runs too late (after user begins interacting)
- Validate user login in php
- optimal taxonomy or custom post types
- Easily add custom HTML outside the main container?
- Query Product categories what have a custom field
- Make Widget appear on Dashboard
- Woocommerce dependent attributes
- How to find and replace (or add) specific word in a specific category?
- Displaying all Custom fields on post except some
- WordPress Install – “end of script output before headers” when running simple php script
- How to appoint different users to different pages?
- How to replace part of shortlink with nothing
- Is there a way to hide a user’s posts from their Activity feed?
- Setting up staging area
- Do i need to use PHP in customizer api?
- Add variable : 1 Week ago
- When is it OK to create a custom table for a plugin? [duplicate]
- Set custom banner image size with wp_customize
- How to display product variations on same row