Support » Developing with WordPress » Sometimes refreshing my pages yields lack of content

  • Hi!

    In short: I’m developing my first site on WordPress, fully from scratch.

    Occasionally, when refreshing any page on the site, the page will be either missing many sections (which are in the Page Template) and/or <?php wp_footer() ?> doesn’t load ANYTHING (no plugin scripts, none of the custom scripts I’ve enqueued to wp_footer). This appears to be entirely random (I can’t replicate it with certainty).

    My header & footer.php files look something like:

    <!DOCTYPE html>
    <?php wp_head(); ?>
    <?php wp_footer(); ?>

    Anyone have any inclination on why this would occur?

    To know when the site “broke” –> if you see something similar to the following screenshot:

    • This topic was modified 2 years, 4 months ago by dtab428. Reason: Adding a screenshot of how to tell that the issue occurred on page load

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Your actual issue is described in your picture: JS files aren’t loading. So the next logical question is how are you enqueing those files? Are you creating your own theme? Are you modifying a theme from the repository? What does your actual code for these things look like?

    @kjodle thank you for your swift reply. See below of how I’m enqueing my separate JS files (I’ve added this to functions.php).

    When I started this project, I basically made a copy of the “TwentySeventeen” theme and began from there.

     * Add Custom JS to the Footer
    function add_scripts()
    	// Register the script like this for a theme:
    	wp_register_script( 'revealer', get_template_directory_uri() . '/js/revealer.js', false, true );
    	wp_register_script( 'custom', get_template_directory_uri() . '/js/custom.js', false, true );
    	// For either a plugin or a theme, you can then enqueue the script:
    	wp_enqueue_script( 'revealer' );
    	wp_enqueue_script( 'custom' );
    add_action( 'wp_footer', 'add_scripts' );
    Moderator bcworkz


    You cannot use wp_footer to enqueue scripts, it fires too late for WP to do what it needs to do. Always use wp_enqueue_scripts action for front end scripts. Admin and login scripts have different actions.

    To cause your script to load in the footer, passing true as the 5th parameter when registering is enough.


    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sometimes refreshing my pages yields lack of content’ is closed to new replies.