Skip to content

Commit

Permalink
カスタムJavaScriptコード関係の出力時のループ処理解除
Browse files Browse the repository at this point in the history
  • Loading branch information
yhira committed Sep 7, 2023
1 parent aa2ba9d commit a94d76a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/custom-fields/custom-js-field.php
Expand Up @@ -40,14 +40,11 @@ function custom_js_custom_box_save_data($post_id) {
if ( !function_exists( 'insert_custom_js' ) ):
function insert_custom_js() {
if ( is_singular() ) {
if ( have_posts() ) : while ( have_posts() ) : the_post();
$custom_js = get_post_meta(get_the_ID(), '_custom_js', true) ;
if ($custom_js) {
echo '<!-- '.THEME_NAME.' Custom JS -->'.PHP_EOL;
echo '<script type="text/javascript">' . $custom_js . '</script>'.PHP_EOL;
}
endwhile; endif;
rewind_posts();
$custom_js = get_post_meta(get_the_ID(), '_custom_js', true);
if ($custom_js) {
echo '<!-- '.THEME_NAME.' Custom JS -->'.PHP_EOL;
echo '<script type="text/javascript">' . $custom_js . '</script>'.PHP_EOL;
}
}
}
endif;
Expand Down

0 comments on commit a94d76a

Please sign in to comment.