Files
Hi-School-Slide-Manager/prompt-builder-reference-and-notes.md
T

1.3 KiB

Dynamic Query for Our Slider on the Preview Page

I need to dynamically filter and override the Divi 5 Group/Carousel module on the "Slide Preview" page based on our URL parameters, or the filters used from our preview dashboard.

We need to intercept divi's loop query and create our own. The header Currently shows all published slides as intended, so it should be just a matter of finding and replacing the query.

Task: Please write a PHP filter in class-hssm-frontend.php to intercept the query args.

  1. Identify the Hook: Look for a filter like divi_query_args, et_pb_blog_query_args, or use pre_get_posts as a fallback. Since this is Divi 5, we need to be careful not to break the visual builder, so ensure !is_admin() or !et_fb_is_enabled() checks are used if we go the pre_get_posts route.

  2. Targeting: The filter must ONLY apply if:

    • We are on the Preview Dashboard page.
    • The $_GET parameters (like hssm_filter) are present in the URL.
  3. The Logic:

    • Sanitize the GET parameter.
    • Modify the query's tax_query (if filtering by Slide Group) or meta_query (if filtering by Store ID) to match the parameter.
  4. Implementation:

    • Add the code to class-hssm-frontend.php.
    • If you are unsure of the exact Divi 5 hook, start by creating a standard pre_get_posts function that targets the main query of that specific page ID.