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?
- How can I fetch loop of post titles via AJAX?
- Include a external PHP file into a WordPress Custom Template
- How to remove hardcoded characters from playlists?
- function_exists call in function.php
- Debugging an error: wp_enqueue_style was called incorrectly
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Refresh page after update_post_meta
- Bulk Image upload and one image for each post?
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Remove css styles from specific page
- Using an Image Slider twice on the same page
- PHP Customization: Taxonomies and Queries, why? [closed]
- Toggle Sidebar Display
- How to speed up admin-ajax.php in wordpress
- My Own layout in WooCommerce pages [closed]
- JQuery not working on WordPress Admin page [closed]
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- How do i use this jquery script on a wordpress site?
- Missing sidebar parameter “fix” – before_content
- Adding country tags automatically
- js file in root loading without
- WooCommerce – Reset quantity input field when variation changes
- How do I get current page ID in WordPress customizer file?
- Customizer: Output default value in Customizer CSS
- Add child pages of parent to navbar PHP
- Load a page into a div with Ajax
- How to remove the cufon script from Dzonia Lite theme [closed]
- Dynamic Sidebars & Echo
- Add_action not working in required file of functions.php
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Adding Custom Slider
- Improve page speed loading using CDN and async or defer attribute
- Change “add to cart” button color based on Woocommerce product category [closed]
- Ajax request returns ‘Array’. How to output the actual results?
- Slick + PHP + ACF + JQuery slide reveal not working
- Displaying recent posts on static page with template-part via shortcode
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Fancybox type popup window that’s not an iframe
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- Form Security: nonce vs. jQuery
- get_template_part for specific page
- How do I create my own .php file with a code part and echo it on different pages?
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- WordPress plugin admin page – using WordPress function in linked php file
- How to remove sidebar primary widget on Mobile on category page [closed]
- Warning: printf(): Too few arguments in helpers.php file
- A $_POST should occur when submit form but is not?
- Shortcode to pull posts
- How to add post thumbnail dynamically using Jquery?
- calling function in external js file
- get_page_templates only return templates with “home” in the filename
- How to refresh a page from jquery [closed]
- Show different website layout if no sidebar added
- How do you remove header sitewide from mobile only?
- PHP inside echo HTML
- WordPress – Query specific category and automatically change category each month
- Check if current post in loop is last on current page
- is_user_logged_in returns false when I access certain pages
- How to pass bloginfo(url) in a jquery
- REST API custom endpoint to fetch pages and posts not working
- Exclude category from woocommerce product category list
- Trying to get pagination working on WP_Query() post grid
- Fix hover images blink
- Input field duplicates on form submit by jQuery
- How to echo a PHP code into WooCommerce variation product?
- Blog Image and Title in Right Sidebar
- Find the method which AJAX GET calls
- Problems with the WordPress loop [closed]
- How to replace hard-coded list of custom taxonomy terms based on custom field query [closed]
- Calling PHP function doesn’t work in index.php
- Add a downloaded JS file to WordPress
- How to run ajax in WordPress Post?
- How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
- if conditional in sidebar plugin Password content shortcode
- Add php function into .js file (for tinyMCE button)
- I am trying to call external database recieving error
- Trying to display ads on only a third of posts in a loop. Keep getting Error 500?
- Add CSS class to PHP Statement
- Load slideshow.css file only if Slideshow is checked / on