In PHP, the number 0 is interpreted as false-ish.
Your if-statement asks for a true-ish condition like this:
If the result of the array_search function is interpreted as true-ish, THEN do the stuff
which means if the result is 0, it is interpreted as false, and the code doesn’t run.
What to do?
Use the identical operator for false like this to check for your wanted condition. Change your if-statement like this:
if ( !( false === array_search( $currentpage, $yearlyarchives, true) ) ){
?> en el <?php echo get_query_var('year');
}
The code will then run if the result of the array search is not identical to false (array_search will return false if the needle is not found).
Happy Coding!
Related Posts:
- Neither the_excerpt() nor the_content() works properly?
- meta_query issue with multiple numerics
- Make archive page show up in search results?
- Displaying a list of tags in my archives page
- Create search box on Archive Custom post type
- Change the text “search result for” on search result page
- how to limit search to post titles?
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- How does WordPress search work behind the scenes?
- Remove some pages from search
- WordPress blog with 30 000 posts: poor search performance
- How do I filter the search results order?
- Link to search page without search parameter
- Search/Replace for editor in HTML-mode
- Custom Post Type Archives by Date with Custom Permalink
- Do I need to sanitize WordPress search query?
- Add custom parameters to JSON API search query?
- Display posts from an author using search parameters (not author template/query_posts)
- How to stop _wpnonce and _wp_http_referer from appearing in URL
- Return all Tags from search results
- Search results with custom loop don’t update when paged
- How do I change WP search results order?
- Does WP search natively return results sorted by type (post, post type, page, category…)?
- How to have Multiple Archives Widgets, one archive widget per category (in a different page)?
- How do I properly redirect outbound links with special characters
- Display Categories in Search Results
- intellisense in wp search
- WordPress custom post type archive with description
- Is it possible to search authors by profile field?
- Template Page Content Made Searchable
- Search result conditonal tag
- Search result by range?
- Get search term not on searh results page?
- Search Result from another wordpress website
- Remove WHERE conditions from search query
- Change default search URL slug in wordpress with Custop Post Type as Search target
- CPT Archive with core Category
- Transliterating search term in another language
- How to exclude events (custom posts) from search, if the start date has already passed?
- How to conditionally pass a parameter to wordpress search to limit post types?
- Change WordPress search Permalink structure
- How to load WP categories into array for autocomplete?
- Custom SQL query on wp_users with the addition of wp_usermeta
- Media searching ignored
- Can I change the default search behavior “OR search” to “AND search”?
- Custom post type archive page thinks I’m not logged in
- Generate list of tags from search results
- Use created page as search results page and custom template
- How do I search dynamically created content?
- Post 2 Post Site Search
- Using search.php without a ‘s’ field in searchform.php
- Search queries don’t seem to work?
- Modifying post content with the_post action hook
- Trying to remove plural ‘s’ from search Query but it’s just removing every letter of the end – what am I doing wrong? Thanks
- Blog search just returns to front page (not search results!)
- Get posts from a top category and group by child categories
- How to insert meta keyword to search result page
- Restrict Search Results to Post Author
- Intelligent Search Filtering
- Custom search Dashboard widget
- Disable character’s replace in search
- WordPress Search Form Issue | Misleading search URL. | Pointing to wrong URL
- Echoing home_url() returns current url in searchform.php
- Remove Page Timestamp via functions.php so it doesn’t show in Google Search Result Description [closed]
- Use pre_get_posts to display search results by meta in specific order
- Prevent search query from taking place when using Google CSE?
- Site Title in my Search URL
- I want empty search returns to home page in my wordpress
- Prevent searches less than 4 characters
- Search wordpress using three different drop down menus
- How to get search result as image rather than page
- Search results – 404 error after hitting enter
- Redirect wordpress search query if its a tag
- Is it possible to show subdomain posts in main domain search result?
- Replacing word in wordpress Search not working Properly
- Tell wordpress to show a single page instead of an archive page
- How to add search box to table results in admin page [closed]
- How might I go about using the API to search for a user by email, but ensuring that it is an exact match?
- Add CPT to search results with pre_get_posts
- Replacing wordpress search with custom code
- Adding custom search button to menu
- Change output URL Search module
- search for single meta_key with numeric array of meta values
- How to customize default wordpress search query
- Customizing Google’s Search box in WordPress [closed]
- Rewriting archive page slug to be different than custom post type slug
- I’ve messed up the admin search functionality. Help!
- Site loads very slow for archive custom post type page
- Content instead Excerpt on term
- Custom search results page not showing excerpt
- 2 loops in archive.php (one for each category)
- Error when searching without any results
- Listing parent section in search results
- Search results: How to add direct jump to anchor?
- how can I make the search return only single random correct result?
- Limit search to posts and pages
- How make Autocomplete with wp_query in post_type attachment
- Exclude category in search results in functions.php
- How to quickly search posts by title in Admin interface