我在Codepen上制作了一个Instagram小部件。它工作得很好,在那里发挥作用。然而,当我尝试将其添加到我的网站时,它会显示出来,看起来工作正常,但我的屏幕上有大量的instagram图像固定在我的网站内容前面(下图)。instagram小部件似乎在所有图像下都能正常工作,所以现在我只需要把屏幕上弹出的图像去掉。然而,当我看控制台时,这些图像似乎出现在wp-nav-menu
和我的页脚元素。即使我把HTML放在帖子里。我已经检查了是否有任何错误,但它没有说有任何错误。有人对我如何解决这个问题有什么建议吗?
编辑:即使我从网站上的任何地方删除HTML,这些图像仍然会出现在我的内容前面。
代码笔-https://codepen.io/elle343/pen/owBoyE
我的HTML
<ul id="rudr_instafeed"></ul>
我的CSS
#rudr_instafeed{
margin: 42px 0 0;
overflow: hidden;
white-space: nowrap;
vertical-align: middle;
position: relative;
text-align: center;
list-style:none;
}
#rudr_instafeed li{
display: inline-block;
vertical-align: middle;
position: relative;
}
#rudr_instafeed li img{
max-height: 260px;
position: relative;
z-index: 0;
}
instagram页脚。js公司
var token = \'5219525.f0b48c7.17327f93adbe4fbb89ccd13a1a226a33\',
num_photos = 20;
jQuery.ajax({
url: \'https://api.instagram.com/v1/users/self/media/recent\',
dataType: \'jsonp\',
type: \'GET\',
data: {access_token: token, count: num_photos},
success: function(data){
console.log(data);
for( x in data.data ){
jQuery(\'ul\').append(\'<li><img src="\'+data.data[x].images.low_resolution.url+\'"></li>\');
}
},
error: function(data){
console.log(data);
}
});
功能。php
function instagramfooter() {
wp_enqueue_script( \'instagramfooter\', get_stylesheet_directory_uri() . \'/js/instagram-footer.js\', array( \'jquery\' ) );
}
add_action( \'wp_enqueue_scripts\', \'instagramfooter\' );
标题。php
<?php
/**
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( \'charset\' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( \'pingback_url\' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="ht-page">
<header id="ht-masthead" class="ht-site-header">
<div class="ht-container ht-clearfix">
<div id="ht-site-branding">
<?php
if ( function_exists( \'has_custom_logo\' ) && has_custom_logo() ) :
the_custom_logo();
else :
if ( is_front_page() ) : ?>
<h1 class="ht-site-title"><a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home"><?php bloginfo( \'name\' ); ?></a></h1>
<?php else : ?>
<p class="ht-site-title"><a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home"><?php bloginfo( \'name\' ); ?></a></p>
<?php endif; ?>
<p class="ht-site-description"><a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" rel="home"><?php bloginfo( \'description\' ); ?></a></p>
<?php endif; ?>
</div><!-- .site-branding -->
<nav id="ht-site-navigation" class="ht-main-navigation">
<div class="toggle-bar"><span></span></div>
<?php
wp_nav_menu( array(
\'theme_location\' => \'primary\',
\'container_class\' => \'ht-menu ht-clearfix\' ,
\'menu_class\' => \'ht-clearfix\',
\'items_wrap\' => \'<ul id="%1$s" class="%2$s">%3$s</ul>\',
) );
?>
</nav><!-- #ht-site-navigation -->
</div>
</header><!-- #ht-masthead -->
<div id="ht-content" class="ht-site-content ht-clearfix">
页脚。php
<footer class="site-footer">
<!-- footer-widgets -->
<div class="footer-widgets clearfix">
<?php if (is_active_sidebar(\'footer1\')) : ?>
<div class="footer-widget-area">
<?php dynamic_sidebar(\'footer1\'); ?>
</div>
<?php endif; ?>
<?php if (is_active_sidebar(\'footer2\')) : ?>
<div class="footer-widget-area">
<?php dynamic_sidebar(\'footer2\'); ?>
</div>
<?php endif; ?>
<?php if (is_active_sidebar(\'footer3\')) : ?>
<div class="footer-widget-area">
<?php dynamic_sidebar(\'footer3\'); ?>
</div>
<?php endif; ?>
<?php if (is_active_sidebar(\'footer4\')) : ?>
<div class="footer-widget-area">
<?php dynamic_sidebar(\'footer4\'); ?>
</div>
<?php endif; ?>
</div><!-- /footer-widgets -->
<div style="display:inline-block;vertical-align:top;">
<p id="copyright">© <?php echo date(\'Y\');?>
<?php bloginfo(\'name\'); ?>
</div>
<nav class="footer-nav" style="display:inline-block;vertical-align:top;">
<?php $args = array( \'theme_location\' => \'footer\' ); ?>
<?php wp_nav_menu( $args ); ?>
</nav>
</footer>
</footer>
</div><!-- container -->
<?php wp_footer(); ?>
</body>
</html>
首页。php
<?php
/*
* Template Name:
*/
get_header();
get_template_part (\'inc/carousel\');
$the_query = new WP_Query( [
\'posts_per_page\' => 15,
\'paged\' => get_query_var(\'paged\', 1)
] );
if ( $the_query->have_posts() ) { ?>
<div id="ajax">
<?php
$i = 0;
$j = 0;
while ( $the_query->have_posts() ) { $the_query->the_post();
if ( $i % 5 === 0 ) { // Large post: on the first iteration and every 7th post after... ?>
<div class="row">
<article <?php post_class( \'col-sm-12 col-md-12\' ); ?>>
<div class="large-front-container">
<?php the_post_thumbnail(\'full\', array(\'class\' => \'large-front-thumbnail\')); ?>
</div>
<div class="front-page-date"><?php echo str_replace(\'mins\', \'minutes\', human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . \' ago\'); ?></div>
<h2><a class="front-page-post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="front-page-post-excerpt"><?php echo get_the_excerpt(); ?></p>
<div class="front-page-post-info">
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php get_template_part( \'front-shop-the-post\' ); ?>
<?php get_template_part( \'share-buttons\' ); ?>
<div class="front-comments"><?php comments_popup_link (\'0\', \'1\', \'%\', \'comment-count\', \'none\'); ?></div>
</div>
</article>
</div>
<?php
} else { // Small posts ?>
<?php if($j % 2 === 0) echo \'<div class="row">\'; ?>
<article <?php post_class( \'col-sm-6 col-md-6\' ); ?>>
<?php the_post_thumbnail(\'full\', array(\'class\' => \'medium-front-thumbnail\')); ?>
<div class="front-page-date"><?php echo human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . \' ago\'; ?></div>
<h2><a class="front-page-post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="front-page-post-excerpt"><?php echo get_the_excerpt(); ?></p>
<div class="front-page-post-info">
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php get_template_part( \'front-shop-the-post\' ); ?>
<?php get_template_part( \'share-buttons\' ); ?>
<div class="front-comments"><?php comments_popup_link (\'0\', \'1\', \'%\', \'comment-count\', \'none\'); ?></div>
</div>
</article>
<?php $j++; if($j % 2 === 0) echo \'</div>\'; ?>
<?php
}
$i++;
}?>
</div>
<?php if(get_query_var(\'paged\') < $the_query->max_num_pages) {
}
}
elseif (!get_query_var(\'paged\') || get_query_var(\'paged\') == \'1\') {
echo \'<p>Sorry, no posts matched your criteria.</p>\';
}
wp_reset_postdata();
get_footer();
功能。php
<?php
define( \'WP_DEBUG\', true );
function btc_scripts() {
wp_enqueue_style(\'style\', get_stylesheet_uri());
wp_enqueue_style( \'bootstrap-style\', get_template_directory_uri() . \'/css/bootstrap.min.css\', array(), \'3.3.7\' );
wp_enqueue_script ( \'bootstrap-js\', get_template_directory_uri() . \'/js/bootstrap.min.js\', array(\'jquery\'), \'3.3.7\', true);
}
add_action( \'wp_enqueue_scripts\', \'btc_scripts\' );
//Navigation Menus
register_nav_menus(array(
\'primary\' => __(\'Primary Menu\'),
\'footer\' => __( \'Footer Menu\'),
));
class CSS_Menu_Walker extends Walker {
var $db_fields = array(\'parent\' => \'menu_item_parent\', \'id\' => \'db_id\');
function start_lvl(&$output, $depth = 0, $args = array()) {
$indent = str_repeat("\\t", $depth);
$output .= "\\n$indent<ul>\\n";
}
function end_lvl(&$output, $depth = 0, $args = array()) {
$indent = str_repeat("\\t", $depth);
$output .= "$indent</ul>\\n";
}
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
global $wp_query;
$indent = ($depth) ? str_repeat("\\t", $depth) : \'\';
$class_names = $value = \'\';
$classes = empty($item->classes) ? array() : (array) $item->classes;
/* Add active class */
if (in_array(\'current-menu-item\', $classes)) {
$classes[] = \'active\';
unset($classes[\'current-menu-item\']);
}
/* Check for children */
$children = get_posts(array(\'post_type\' => \'nav_menu_item\', \'nopaging\' => true, \'numberposts\' => 1, \'meta_key\' => \'_menu_item_menu_item_parent\', \'meta_value\' => $item->ID));
if (!empty($children)) {
$classes[] = \'has-sub\';
}
$class_names = join(\' \', apply_filters(\'nav_menu_css_class\', array_filter($classes), $item, $args));
$class_names = $class_names ? \' class="\' . esc_attr($class_names) . \'"\' : \'\';
$id = apply_filters(\'nav_menu_item_id\', \'menu-item-\'. $item->ID, $item, $args);
$id = $id ? \' id="\' . esc_attr($id) . \'"\' : \'\';
$output .= $indent . \'<li\' . $id . $value . $class_names .\'>\';
$attributes = ! empty($item->attr_title) ? \' title="\' . esc_attr($item->attr_title) .\'"\' : \'\';
$attributes .= ! empty($item->target) ? \' target="\' . esc_attr($item->target ) .\'"\' : \'\';
$attributes .= ! empty($item->xfn) ? \' rel="\' . esc_attr($item->xfn ) .\'"\' : \'\';
$attributes .= ! empty($item->url) ? \' href="\' . esc_attr($item->url ) .\'"\' : \'\';
$item_output = $args->before;
$item_output .= \'<a\'. $attributes .\'><span>\';
$item_output .= $args->link_before . apply_filters(\'the_title\', $item->title, $item->ID) . $args->link_after;
$item_output .= \'</span></a>\';
$item_output .= $args->after;
$output .= apply_filters(\'walker_nav_menu_start_el\', $item_output, $item, $depth, $args);
}
function end_el(&$output, $item, $depth = 0, $args = array()) {
$output .= "</li>\\n";
}
}
// Add Widget Areas
function ourWidgetsInit() {
register_sidebar( array(
\'name\' => \'Sidebar\',
\'id\' => \'sidebar1\',
\'before_widget\' => \'<div class="widget-item">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widget-title">\',
\'after_title\' => \'</h2>\',
));
register_sidebar( array(
\'name\' => \'Footer Area 1\',
\'id\' => \'footer1\',
\'before_widget\' => \'<div class="widget-item">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widget-title">\',
\'after_title\' => \'</h2>\',
));
register_sidebar( array(
\'name\' => \'Footer Area 2\',
\'id\' => \'footer2\',
\'before_widget\' => \'<div class="widget-item">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widget-title">\',
\'after_title\' => \'</h2>\',
));
register_sidebar( array(
\'name\' => \'Footer Area 3\',
\'id\' => \'footer3\',
\'before_widget\' => \'<div class="widget-item">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widget-title">\',
\'after_title\' => \'</h2>\',
));
register_sidebar( array(
\'name\' => \'Footer Area 4\',
\'id\' => \'footer4\',
\'before_widget\' => \'<div class="widget-item">\',
\'after_widget\' => \'</div>\',
\'before_title\' => \'<h2 class="widget-title">\',
\'after_title\' => \'</h2>\',
));
}
add_action(\'widgets_init\', \'ourWidgetsInit\');
// Theme setup
function learningWordpress_setup() {
// Navigation Menus
register_nav_menus(array(
\'primary\' => __(\'Primary Menu\'),
\'footer\' => __( \'Footer Menu\'),
));
// Add featured image support
add_theme_support(\'post-thumbnails\');
add_image_size(\'medium-thumbnail\', 446, 345, true);
add_image_size(\'large-thumbnail\', 1386, 595, true);
add_image_size(\'popular-posts\', 256, 256, true);
}
add_action(\'after_setup_theme\', \'learningWordpress_setup\');
// Register Custom Taxonomy
function location() {
$labels = array(
\'name\' => \'Locations\',
\'singular_name\' => \'Location\',
\'menu_name\' => \'Location\',
\'all_items\' => \'All Items\',
\'parent_item\' => \'Parent Item\',
\'parent_item_colon\' => \'Parent Item:\',
\'new_item_name\' => \'New Item Name\',
\'add_new_item\' => \'Add New Item\',
\'edit_item\' => \'Edit Item\',
\'update_item\' => \'Update Item\',
\'view_item\' => \'View Item\',
\'separate_items_with_commas\' => \'Separate items with commas\',
\'add_or_remove_items\' => \'Add or remove items\',
\'choose_from_most_used\' => \'Choose from the most used\',
\'popular_items\' => \'Popular Items\',
\'search_items\' => \'Search Items\',
\'not_found\' => \'Not Found\',
\'no_terms\' => \'No items\',
\'items_list\' => \'Items list\',
\'items_list_navigation\' => \'Items list navigation\',
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
);
register_taxonomy( \'location\', array( \'post\' ), $args );
}
add_action( \'init\', \'location\', 0 );
// Carousel
function carousel_scripts() {
wp_enqueue_style( \'owl.carousel\', get_template_directory_uri() . \'/css/owl.carousel.css\' );
wp_enqueue_style( \'owl.theme\', get_template_directory_uri() . \'/css/owl.theme.css\' );
wp_enqueue_script( \'owl.carousel\', get_template_directory_uri() . \'/js/owl.carousel.js\', array(\'jquery\'), \'20120206\', true );
wp_enqueue_script( \'effects\', get_template_directory_uri() . \'/js/effects.js\', array(\'jquery\'), \'20120206\', true );
}
add_action( \'wp_enqueue_scripts\', \'carousel_scripts\' );
// Custom control for carousel category
if (class_exists(\'WP_Customize_Control\')) {
class WP_Customize_Category_Control extends WP_Customize_Control {
public function render_content() {
$dropdown = wp_dropdown_categories(
array(
\'name\' => \'_customize-dropdown-category-\' . $this->id,
\'echo\' => 0,
\'show_option_none\' => __( \'— Select —\' ),
\'option_none_value\' => \'0\',
\'selected\' => $this->value(),
)
);
$dropdown = str_replace( \'<select\', \'<select \' . $this->get_link(), $dropdown );
printf(
\'<label class="customize-control-select"><span class="customize-control-title">%s</span> %s</label>\',
$this->label,
$dropdown
);
}
}
}
// Register slider customizer section
add_action( \'customize_register\' , \'carousel_options\' );
function carousel_options( $wp_customize ) {
$wp_customize->add_section(
\'carousel_section\',
array(
\'title\' => \'Carousel settings\',
\'priority\' => 202,
\'capability\' => \'edit_theme_options\',
)
);
$wp_customize->add_setting(
\'carousel_setting\',
array(
\'default\' => \'\',
)
);
$wp_customize->add_control(
new WP_Customize_category_Control(
$wp_customize,
\'carousel_category\',
array(
\'label\' => \'Category\',
\'settings\' => \'carousel_setting\',
\'section\' => \'carousel_section\'
)
)
);
$wp_customize->add_setting(
\'count_setting\',
array(
\'default\' => \'6\',
)
);
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
\'carousel_count\',
array(
\'label\' => __( \'Number of posts\', \'theme_name\' ),
\'section\' => \'carousel_section\',
\'settings\' => \'count_setting\',
\'type\' => \'text\',
)
)
);
}
//JQUERY
function my_theme_scripts() {
wp_enqueue_script( \'my-great-script\', get_template_directory_uri() . \'/js/loadmore.js\', array( \'jquery\' ), \'1.0.0\', true );
}
add_action( \'wp_enqueue_scripts\', \'my_theme_scripts\' );
//MORE J
function my_admin_scripts() {
wp_enqueue_script( \'my-great-script\', plugin_dir_url(\' /js/fontend.min.js\' ) . \'/js/fontend.min.js\', array( \'jquery\' ), \'1.0.0\', true );
}
add_action( \'admin_enqueue_scripts\', \'my_admin_scripts\' );
//MORE COMMENTS
/**
* Return the default comment form fields.
* Customize comment form default fields.
* Move the comment_field below the author, email, and url fields.
*/
function wpse250243_comment_form_default_fields( $fields ) {
$commenter = wp_get_current_commenter();
$user = wp_get_current_user();
$user_identity = $user->exists() ? $user->display_name : \'\';
$req = get_option( \'require_name_email\' );
$aria_req = ( $req ? " aria-required=\'true\'" : \'\' );
$fields = [
\'author\' => \'<p class="comment-form-author">\' . \'<label for="author">\' . __( \'\', \'textdomain\' ) . ( $req ? \' <span class="required"></span>\' : \'\' ) . \'</label> \' .
\'<input id="author" name="author" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) . \'" size="30" maxlength="245"\' . $aria_req . $html_req . \' /></p>\',
\'email\' => \'<p class="comment-form-email"><label for="email">\' . __( \'\', \'textdomain\' ) . ( $req ? \' <span class="required"></span>\' : \'\' ) . \'</label> \' .
\'<input id="email" name="email" \' . ( $html5 ? \'type="email"\' : \'type="text"\' ) . \' value="\' . esc_attr( $commenter[\'comment_author_email\'] ) . \'" size="30" maxlength="100" aria-describedby="email-notes"\' . $aria_req . $html_req . \' /></p>\',
\'url\' => \'<p class="comment-form-url"><label for="url">\' . __( \'\', \'textdomain\' ) . \'</label> \' .
\'<input id="url" name="url" \' . ( $html5 ? \'type="url"\' : \'type="text"\' ) . \' value="\' . esc_attr( $commenter[\'comment_author_url\'] ) . \'" size="30" maxlength="200" /></p>\',
];
return $fields;
}
add_filter( \'comment_form_default_fields\', \'wpse250243_comment_form_default_fields\' );
/**
* Remove the original comment field because we\'ve added it to the default fields
* using wpse250243_comment_form_default_fields(). If we don\'t do this, the comment
* field will appear twice.
*/
function wpse250243_comment_form_defaults( $defaults ) {
if ( isset( $defaults[ \'comment_field\' ] ) ) {
$defaults[ \'comment_field\' ] = \'\';
}
return $defaults;
}
add_filter( \'comment_form_defaults\', \'wpse250243_comment_form_defaults\', 10, 1 );
//MOVE COMMENTS
function wpb_move_comment_field_to_bottom( $fields ) {
$comment_field = $fields[\'comment\'];
unset( $fields[\'comment\'] );
$fields[\'comment\'] = $comment_field;
return $fields;
}
add_filter( \'comment_form_fields\', \'wpb_move_comment_field_to_bottom\' );
//COMMENTS
add_filter( \'comment_form_default_fields\', \'wpse_62742_comment_placeholders\' );
/**
* Change default fields, add placeholder and change type attributes.
*
* @param array $fields
* @return array
*/
function wpse_62742_comment_placeholders( $fields )
{
$fields[\'author\'] = str_replace(
\'<input\',
\'<input placeholder="\'
/* Replace \'theme_text_domain\' with your theme’s text domain.
* I use _x() here to make your translators life easier. :)
* See http://codex.wordpress.org/Function_Reference/_x
*/
. _x(
\'Name\',
\'comment form placeholder\',
\'theme_text_domain\'
)
. \'"\',
$fields[\'author\']
);
$fields[\'email\'] = str_replace(
\'<input id="email" name="email" type="text"\',
/* We use a proper type attribute to make use of the browser’s
* validation, and to get the matching keyboard on smartphones.
*/
\'<input type="email" placeholder="Email" id="email" name="email"\',
$fields[\'email\']
);
$fields[\'url\'] = str_replace(
\'<input id="url" name="url" type="text"\',
// Again: a better \'type\' attribute value.
\'<input placeholder="Website" id="url" name="url" type="url"\',
$fields[\'url\']
);
return $fields;
}
//Comments Continued
if ( get_option (\'thread_comments\') ) {
wp_enqueue_script(\'comment-reply\');
}
//Comments
function custom_comments ($comment, $args, $depth) {
$GLOBALS[\'comment\'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<header class="comment-author-vcard">
<?php printf (__(\'<cite_class="fn">%s</cite> <span class="says"></span>\'), get_comment_author_link()) ?>
</header>
<div class="comment-meta"><a href="<?php echo htmlspecialchars( get_comment_link($comment->comment_ID )) ?>"></a></div>
<?php if ($comment->comment_approved == \'0\') : ?>
<em><?php _e(\'Your comment is awaiting moderation.\') ?></em>
<?php endif; ?>
<div class="comment-content"><?php comment_text() ?></div>
<div class="comment-time"><?php printf(__(\'%1$s at %2$s\'), get_comment_date(), get_comment_time() ) ?><?php edit_comment_link(__(\'(Edit)\'), \' \', \' \') ?><?php comment_reply_link(array_merge($args, array(\'depth\' => $depth, \'max_depth\' => $args[\'max_depth\'] ))) ?></div>
<div class="reply">
</div>
</div>
<?php
}
//New Menus
function register_my_menus() {
register_nav_menus(
array(
\'new-menu\' => __( \'Footer Menu Secondary\' ),
\'another-menu\' => __( \'Another Menu\' ),
\'an-extra-menu\' => __( \'An Extra Menu\' )
)
);
}
add_action( \'init\', \'register_my_menus\' );
// Wordpress
function load_fonts() {
wp_register_style(\'et-googleFonts\', \'https://fonts.googleapis.com/css?family=David+Libre|Crimson+Text|Questrial|Raleway:200,300,400,600,700|Montserrat|Catamaran|Pathway+Gothic+One|PT+Serif|Days+One|Lato:300,400,700|Work+Sans:400,500,600,700\');
wp_enqueue_style( \'et-googleFonts\');
}
add_action(\'wp_print_styles\', \'load_fonts\');
//REMOVE P
function filter_ptags_on_images($content){
return preg_replace(\'/<p>\\\\s*?(<a .*?><img.*?><\\\\/a>|<img.*?>)?\\\\s*<\\\\/p>/s\', \'\\1\', $content);
}
add_filter(\'the_content\', \'filter_ptags_on_images\');
// Popular Posts
function wpb_set_post_views($postID) {
$count_key = \'wpb_post_views_count\';
$count = get_post_meta($postID, $count_key, true);
if($count==\'\'){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, 0);
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( \'wp_head\', \'adjacent_posts_rel_link_wp_head\', 10, 0);
function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
wpb_set_post_views($post_id);
}
add_action( \'wp_head\', \'wpb_track_post_views\');
//search
function searchfunction() {
wp_enqueue_script( \'my-script\', get_stylesheet_directory_uri() . \'/js/search.js\', array( \'jquery\' ) );
}
add_action( \'wp_enqueue_scripts\', \'searchfunction\' );
//hamburger menu
function hamburgermenu() {
wp_enqueue_script( \'hamburger-menu\', get_stylesheet_directory_uri() . \'/js/hamburgermenu.js\', array( \'jquery\' ) );
}
add_action( \'wp_enqueue_scripts\', \'hamburgermenu\' );
//instagram footer
function instagramwidget() {
wp_enqueue_script ( ‘instagramfooter\', get_template_directory_uri() . \'/js/instagram-footer\', array(\'jquery\'), \'2.2.4\', true);
}
add_action( \'wp_enqueue_scripts\', ‘instagramfooter\' );
问题截图