2015-12-21 34 views
-1

我嘗試添加一些javascript代碼之後的內容和之前的相關新聞鏈接,但是我的javascript代碼顯示爲之後的相關新聞。如何在Wordpress中添加一些javascript代碼

我嘗試這個在這裏添加我的代碼: 主題\ themes_name \ content_single.php:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
<header class="entry-header"> 
    <?php the_title('<h1 class="entry-title">', '</h1>'); ?> 

    <div class="entry-meta"> 
     <?php accesspress_basic_posted_on(); ?> 
    </div><!-- .entry-meta --> 
</header><!-- .entry-header --> 
<div class="entry-content"> 
     <?php the_post_thumbnail(); ?> 
    <?php the_content(); ?> 
    <?php 
     wp_link_pages(array(
      'before' => '<div class="page-links">' . __('Pages:', 'accesspress-basic'), 
      'after' => '</div>', 
     )); 
    ?> 
</div><!-- .entry-content --> 

<div class="ads-baroot ads-desc"> 
**my Codes here...** 
</div> 
+0

這是非常不清楚你問什麼叫。在這段代碼中我沒有看到任何JS。什麼是你的問題? – vard

+0

我的JavaScript代碼運行良好,並顯示我的結果,但顯示相關新聞鏈接後,我需要顯示我的代碼之前,相關新聞鏈接 –

+1

哪裏是相關的新聞,內容,最後JS? –

回答

0

的相關新聞在<?php the_content(); ?>可能被解析,你的JavaScript代碼是低於。因此,javascript結果顯示在相關文章的下方。

0

創建腳本文件,並添加主題默認的JS文件夾,並在你的主題function.php

function custom_scripts() { 

    wp_enqueue_script('customjquery', get_template_directory_uri() . '/js/customjquery.js', array(), '0001', true); 

} 
add_action('wp_head', 'custom_scripts'); 
相關問題