The “magic hybrid of jQuery and php” is called “AJAX”, at least in this case. You will need to use the Javascript to conditionally make another request to the server. The PHP runs on the server and so has no idea how tall the page is. The Javascript runs in the browser and can work out the window height but can’t run the PHP directly. The only choice is AJAX.
WordPress has an AJAX API, that makes AJAX requests very easy. There are plenty of examples in the Codex for using the AJAX API and plenty of questions here about it as well. Get started. If you have trouble, edit your question with the specifics.
Related Posts:
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- How can I loop into two different DIVS without repeating the DIVs
- Why is this Ajax not working?
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- populate form fields in a loop with ajax
- Menu jumping when calling it via PHP
- How to disable controls in theme customizer?
- if statement with is_active_sidebar()
- Royalty-Free Sliders used in theme development
- Theme not calling Jquery properly
- jQuery accordion menu
- Why the dynamic_sidebar() call is putted into an ul tag?
- Removed jQuery script from header.php , any problems?
- How to change PHP variables with AJAX request in WordPress
- Custom theme admin-ajax.php 400 (Bad Request)
- Extend the WP_Customize_Image_Control class to change its non-frame $button_labels
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Listing current pages subp page in list items in the sidebar
- Sidebar doesnt get updated?
- Woocommerce add to cart quantity buttons with AJAX
- Adding country tags automatically
- write custom woocommerce templates and forms
- Implement toggle switch for theme options in settings API
- js file in root loading without
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- WooCommerce – Reset quantity input field when variation changes
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- class click counter save number
- Using a variable in is_page(array())
- Trigger popup in a php if/else statement
- Anyway to output the registration form like the login form with wp_login_form()?
- How do I get current page ID in WordPress customizer file?
- Customizer: Output default value in Customizer CSS
- How to load a template-part based on a url wildcard?
- WordPress does not load page.php, return 404.php
- Slider loading issue
- Checking for new message using AJAX and PHP. Server overload?
- jQuery not defined
- How can i upload images in an admin page?
- Where to edit the template that is generating the code for dynamic_sidebar left-sidebar in the Understrap theme? [closed]
- AJAX request status 200 but no actual “response”
- Multiple WordPress Menus that will only display all pages
- Conditional Header in wordpress
- Set the checkbox as checked by default at options page
- Add child pages of parent to navbar PHP
- How can I create a list of page titles from custom meta values?
- Load a page into a div with Ajax
- How to select the contents in the text view textrea in wp_editor?
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Theme Options Page – User Updates Logo
- wordpress count link clicks by ip address
- Converting HTML Template to WordPress Theme
- Proper syntax or method for keeping url in modified isotope / category links
- How to use my style.css file outside of wordpress subdomain?
- How to show part of the_content?
- Wp-login appears White Screen, Error: Cannot modify header information
- ajax, right way to do it and make it works?
- How to remove the cufon script from Dzonia Lite theme [closed]
- get_the_tags() not iterating through for/while loop, but will with foreach
- Dynamic Sidebars & Echo
- Hide categories that are not used in the post type
- Is there a way to programmatically create multiple pages utilizing the same template but different content from a json file?
- Ajax load more posts with multiple tax query
- WordPress Sending data to Ajax with select option
- How do I add custom bulk actions to multiple custom post types?
- Add_action not working in required file of functions.php
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- WordPress ajax doesn’t display object method on jQuery .change() function
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- what is the best practice to add new field to an api route
- How to design a table based on css values set from admin/dashboard
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Can’t access variable outside for loop
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- add custom link to wordpress media gallery modal
- Adding Custom Slider
- Need Help Fixing My Iframes [closed]
- Avoid parallax images hardcoding
- Improve page speed loading using CDN and async or defer attribute
- Ajax date_query not working past the first iteration
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- AJAX pagination, update current page
- Limit Widgets to Sidebar ID’s
- Save Search System
- adjust section according to country?
- Error in custom php function doesn’t exist
- dynamic dependent select dropdown
- Customizer: active_callback and sanitize_callback incompatibility?
- post created but no permalink
- Change “add to cart” button color based on Woocommerce product category [closed]
- How can I get the values of my WordPress $wpdb query in Jquery?
- Ajax request returns ‘Array’. How to output the actual results?
- Ajax load more button for comments wordpress
- Slick + PHP + ACF + JQuery slide reveal not working
- How to add a do_action on refreshing of WP customizer?