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
- Consistent and Admissible Heuristics
- Solr vs. ElasticSearch
- How do you make Vim unhighlight what you searched for?
- grep for special characters in Unix
- Search is always exact [closed]
- how to limit search to post titles?
- How to create live autofill search?
- How can I implement a location based (zip code) search in WordPress?
- How to highlight search terms without plugin
- How do I remove Pages from search?
- Custom Post Type Archives by Year & Month?
- Empty search returns home page, how to return not found search page?
- Get custom post type slug for an archive page
- How to search for (partial match) display names of WordPress users?
- How to make search include data from wp_postmeta?
- How does WordPress search work behind the scenes?
- Remove some pages from search
- Limit search to latin characters
- How to look at code in WordPress repositories without downloading?
- Extend WordPress search to include user search
- Display search results within the same page
- Empty search input returns all posts
- How can i move search results onto a specific page?
- Remove meta robots tag from wp_head
- WordPress blog with 30 000 posts: poor search performance
- Template issues getting ajax search results
- Insert DIV container below 1st search result
- Unified search across separate WordPress installations
- Search in WordPress – Difference of searchpage.php, searchform.php and search.php?
- How to make WordPress search prioritise page titles?
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- How to add the author search in the default wordpress search?
- How do I filter the search results order?
- How to insert a span inside a search form?
- How do I redirect /search/ to wordpress search template?
- How to search for users based on added user metadata
- Search by Post ID and display content of the post in search result
- Extending search query with additional $sentence value
- Proper way of making custom post type landing page or archive page
- Link to search page without search parameter
- Search/Replace for editor in HTML-mode
- Custom Post Type Archives by Date with Custom Permalink
- How do I search events between two set dates inside WP?
- Search only blog posts (default WP search widget)
- Exclude pages from WordPress search result page
- How to pass a search $_GET parameter to a new custom search page?
- Do I need to sanitize WordPress search query?
- Disable Redirect to Product Page on Search Results Page in WooCommerce [closed]
- Search Using Post ID
- Change title in head on Archive page
- Custom Post Type Archives with 0 Posts Redirects as 404
- Let user change posts per page
- WP User Query with search columns and meta query
- Exclude top-level pages from search results
- WordPress 3.6, searchform.php problems
- Search in non-English language returns only one result
- Complex Search functionality. Advice needed
- Page is defaulting to archive page and not designated template
- Get user role by using user_id in buddypress
- How to use next_post_link and previous_post_link on single posts in search results
- Why is there a class=”screen-reader-text” on my search button?
- template_include for search.php makes WordPress think its on the home page
- Turning Broken URLs Into Search Terms?
- How can I implement faceted search with WordPress 3.x?
- can’t limit search to only pages
- Add custom parameters to JSON API search query?
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Combining Meta_Query key values for one array
- Change the Search Base in a multi language wordpress
- Display posts from an author using search parameters (not author template/query_posts)
- Search: Only One Result Returned
- Include custom table into search results
- How to redirect search result page to post
- Create multiple Search functions for posts / custom post types and everything
- How to stop _wpnonce and _wp_http_referer from appearing in URL
- Return all Tags from search results
- How to exclude post body from WP search
- Custom Permalinks Break Search Pagination
- Output yearly archive within a page
- Search results with custom loop don’t update when paged
- ElasticPress Indexing multiple sites
- paginate function in archive for custom-post-type
- Search uses index.php instead of search.php on renaming search field from “s”
- How to search through pdf media files?
- Search outside of the “loop”
- Replace URL with Site Title in Search Results
- How do I change WP search results order?
- Include Author profile in search results
- Force WP to use a certain search template
- Set minimum number of characters in the search
- search.php template not loading results
- Adding arg to search results page
- search only pages if on page
- Search results URL without query string variables