$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Theme is Enqueueing Everything in Footer|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Theme is Enqueueing Everything in Footer

matteradmin10PV0评论

I am developing a theme. Nothing special at the moment. In my functions.php I've added support for post thumbnails, title tag, and have one custom post type.

In my header I have wp_head() and footer has wp_footer(). The issue I'm facing is that despite all this, the standard css and javascript items are being enqueued in the footer, even the admin bar stuff.

Plugins used are:

  • Gravity Forms
  • Gravity Forms Survey
  • Advanced Custom Fields

The stuff is still being enqueued in the footer, even when I disable these plugins. If I switch to another theme, the stuff is enqueued in the header as expected.

At the moment, I have 4 files not counting the functions.php:

  • header.php
  • footer.php
  • index.php
  • single-survey.php

header.php (once I have this working I'll enqueue everything)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Favicons-->
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" type="image/x-icon" href="img/apple-touch-icon-57x57-precomposed.png">
    <link rel="apple-touch-icon" type="image/x-icon" sizes="72x72" href="img/apple-touch-icon-72x72-precomposed.png">
    <link rel="apple-touch-icon" type="image/x-icon" sizes="114x114" href="img/apple-touch-icon-114x114-precomposed.png">
    <link rel="apple-touch-icon" type="image/x-icon" sizes="144x144" href="img/apple-touch-icon-144x144-precomposed.png">

    <!-- GOOGLE WEB FONT -->
    <link href="+Condensed:300,300i,400,400i,700,700i" rel="stylesheet">

    <!-- BASE CSS -->
    <link href="<?php echo get_template_directory_uri(); ?>/css/bootstrap.min.css" rel="stylesheet">
    <link href="<?php echo get_template_directory_uri(); ?>/css/style.css" rel="stylesheet">
    <link href="<?php echo get_template_directory_uri(); ?>/css/responsive.css" rel="stylesheet">
    <link href="<?php echo get_template_directory_uri(); ?>/css/menu.css" rel="stylesheet">
    <link href="<?php echo get_template_directory_uri(); ?>/css/animate.min.css" rel="stylesheet">
    <link href="<?php echo get_template_directory_uri(); ?>/css/icon_fonts/css/all_icons_min.css" rel="stylesheet">
    <link href="<?php echo get_template_directory_uri(); ?>/css/skins/square/grey.css" rel="stylesheet">

    <!-- YOUR CUSTOM CSS -->
    <link href="<?php echo get_template_directory_uri(); ?>/css/custom.css" rel="stylesheet">

    <script src="<?php echo get_template_directory_uri(); ?>/js/modernizr.js"></script>
    <!-- Modernizr -->
    <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>   

footer.php

    <footer id="home" class="clearfix">
        <p>&copy; <?php echo date('Y'); ?> My Company</p>   
    </footer>
    <!-- end footer-->

<?php wp_footer();?>

</body>
</html>

functions.php

 <?php

add_theme_support( 'post-thumbnails' ); 
add_theme_support( 'title-tag' );


add_action('init', 'survey_custom_post');

function survey_custom_post() {

    $labels = array(
        'name' => _x('Survey', 'post type general name'),
        'singular_name' => _x('Survey', 'post type singular name'),
        'add_new' => _x('Add New', 'Survey'),
        'add_new_item' => __('Add New Survey'),
        'edit_item' => __('Edit Survey'),
        'new_item' => __('New Survey'),
        'view_item' => __('View Survey'),
        'search_items' => __('Search Survey'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => '',
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => 5,
        'supports' => array('title','editor','thumbnail')
        );
        //'taxonomies' => array('category'); 

    register_post_type( 'survey' , $args );
     }

     ?>

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far