- Help Center Home
- Getting started
- Introducing FacetWP
- Installation and updates
- FAQ
- How it works
- What are facets?
- Facet types
- Built-in facet types
- Checkboxes
- Dropdown
- Radio
- fSelect
- Hierarchy
- Slider
- Search
- Autocomplete
- Date Range
- Number Range
- Star Rating
- Proximity
- Pager + load more
- Sort
- Reset
- User Selections
- Add-on facet types
- Map
- Hierarchy Select
- Range List
- Time Since
- A-Z Listing
- Color
- Custom facet types
- Custom facet types
- Indexing
- Listing templates
- Extras & integrations
- Add-on features and extras
- Using FacetWP with …
- Built-in integrations
- Advanced Custom Fields
- WooCommerce
- SearchWP
- WP-CLI
- Add-on integrations
- Blocks
- Bricks
- Elementor
- Beaver Builder
- WP Recipe Maker and Tasty Recipes
- Relevanssi
- WPML and Polylang
- Meta Box
- Flatsome (theme)
- External integrations
- Breakdance
- Document Library Pro
- Listify (theme)
- Listable (theme)
- WPGraphQL
- Tips & tricks
- WordPress multi-site
- WP All Import
- WebToffee Import Export
- WP Job Manager
- Easy Digital Downloads
- EDD Reviews
- Intuitive Custom Post Order
- Custom Taxonomy Order
- Post Types Order
- Genesis framework
- WP External Links
- ElasticPress
- Yoast SEO
- All in One SEO (Pro)
- The Events Calendar Pro
- Google Analytics 4
- Image Optimization by Optimole
- Meow Lightbox
- Cookiebot
- Caching, hosting & security
- Object caching
- WP Rocket
- Cloudflare
- WP Engine
- Pressable
- New Relic
- WordPress REST API Authentication
- All-In-One Security (AIOS)
- Fast Velocity Minify
- Incompatibilities
- Incompatible plugins and themes
- Troubleshooting
- Troubleshooting guide
- Using the right query
- Common issues
- Common indexing issues
- Get support
- Developers
- Hooks reference
- Indexing hooks
- Querying hooks
- Output hooks
- facetwp_facet_display_value
- facetwp_facet_html
- facetwp_facet_render_args
- facetwp_facet_pager_link
- facetwp_facet_sort_options
- facetwp_template_html
- facetwp_shortcode_html
- facetwp_render_params
- facetwp_render_output
- facetwp_builder_item_value
- facetwp_builder_dynamic_tags
- facetwp_builder_dynamic_tag_value
- Advanced hooks
- Deprecated hooks
- JavaScript reference
- Shortcodes reference
- FacetWP REST API
- How FacetWP works
- The FacetWP URL
- FacetWP speed and limits
- Tutorials
- Code snippets
- Feedback
- What’s new
- Changelog
- News & announcements
How to use get_query_var(‘paged’) with FacetWP
If your theme or your custom code uses if ( get_query_var('paged') )
to check if you are on a paginated page with a page number higher than 1
, you may run into confusing issues when using FacetWP on the page.
The reason for this is that FacetWP sets the paged
query variable slightly different on page #1 than WordPress. The below table hightlights the difference:
WordPress | FacetWP | |
---|---|---|
On page: | #1 | #1 |
get_query_var('paged') |
0 (int) |
1 (int) |
if (get_query_var('paged')) |
false |
true |
On page: | #2 | #2 |
get_query_var('paged') |
2 (int) |
2 (int) |
if (get_query_var('paged')) |
true |
true |
In WordPress, we are on page #1 if the paged
query variable is 0
(or not set). This results in if ( get_query_var('paged' )
returning false
on page #1. However, FacetWP sets paged
to 1
on page #1, resulting in if (get_query_var('paged'))
returning true
on page #1.
This difference can lead to unexpected results. For example, breadcrumb-generating code that adds “/ Page 1” on page #1, where your intention is to only add this to page numbers higher than 1.
You’ll mostly see this issue happening when loading a page with facet selections in the URL, or if you pre-select facets with the facetwp_preload_url_vars hook.
The way to fix this discrepancy is to not use:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
if ( get_query_var('paged') ) { // your code }
but instead, to use the check like this:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
if ( get_query_var('paged') > 1 ) { // your code }
See also
Last updated: December 16, 2024