• 解決済 リキャーナ

    (@mr_hronoobuu)


    お世話になります。
    functions.phpに下記の記述をしました。再度URLにアクセスした際、画面が白くなりました。
    色々調べてますが解決策が見つからず困っております。以上、宜しくお願い致します。

    // 下記のコードをfunctions.phpに記述しました。
    if (!is_admin()) {
    function register_script(){
    wp_deregister_script(‘jquery’);
    wp_register_script(‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js’, array(), ‘1.11.1’);
    wp_register_script(‘flexslider’,get_stylesheet_directory_uri() . ‘/library/js/jquery.flexslider-min.js’, array(‘jquery’), ‘2.1’);
    wp_register_script(‘jquery.jcarousel’,get_stylesheet_directory_uri() . ‘/library/js/jquery.jcarousel.min.js’, array(‘jquery’), NULL);
    wp_register_script(‘pikachoose’,get_stylesheet_directory_uri() . ‘/library/js/jquery.pikachoose.js’, array(‘jquery’), ‘1.0’);
    wp_register_script(‘masonry.min’,get_stylesheet_directory_uri() . ‘/library/js/masonry.min.js’, array(”), ‘3.1.5’, true);
    wp_register_script(‘imagesloaded’,get_stylesheet_directory_uri() . ‘/library/js/imagesloaded.pkgd.js’, array(‘masonry’), ‘1.0’, true);
    wp_register_script(‘headroom’,get_stylesheet_directory_uri() . ‘/library/js/headroom.min.js’, array(‘imagesloaded’), ‘0.3.11’, true);
    wp_register_script(‘headroommin’,get_stylesheet_directory_uri() . ‘/library/js/jQuery.headroom.min.js’, array(‘headroom’), ‘0.3.11’, true);
    wp_register_script(‘slidemenu’,get_stylesheet_directory_uri() . ‘/library/js/slidemenu.js’, array(‘slidemenu’), NULL, true);
    }
    function add_script() {
    register_script();
    if(in_category(‘item’) || is_home()) {
    wp_enqueue_script(‘jquery’);
    wp_enqueue_script(‘flexslider’);
    wp_enqueue_script(‘jquery.jcarousel’);
    wp_enqueue_script(‘pikachoose’);
    wp_enqueue_script(‘masonry.min’);
    wp_enqueue_script(‘imagesloaded’);
    wp_enqueue_script(‘headroom’);
    wp_enqueue_script(‘headroommin’);
    wp_enqueue_script(‘slidemenu’);
    }
    }
    add_action(‘wp_print_scripts’, ‘add_script’);
    }

4件の返信を表示中 - 1 - 4件目 (全4件中)
  • http://ja.forums.wordpress.org/topic/132908
    http://ja.forums.wordpress.org/topic/132906

    重複しています。

    functions.phpに下記の記述をしました。

    同ファイルをバックアップファイルに戻してもダメでしょうか。

    トピック投稿者 リキャーナ

    (@mr_hronoobuu)

    ありがとうございます。無事にスタイルを適用することができました。あと、1つ質問があります。

    それは、functions.phpを修正後に表示されました。

    エラー・メッセージ :: Notice: Use of undefined constant rand – assumed ‘rand’ in functions.php on line 148

    直訳すると「 注意:未定義の定数·ランドの使用 – ライン149上のfunctions.phpに「ランド」と想定 」

    下記は記述したコードです。

    function related_items_list(){
    global $post;
    $categories = get_the_category($post->ID);
    if( $categories ){
    $category_ids = array();
    foreach( $categories as $category){
    $category_id = $category->term_id;
    $category_child = get_term_children($category_id, ‘category’);
    if($category_child != true){
    $category_ids[] = $category->term_id ;
    }
    }
    $args=array(
    ‘category__in’ => $category_ids,
    ‘post__not_in’ => array($post->ID),
    ‘posts_per_page’=> 3,
    ‘ignore_sticky_posts’=> 1,
    ‘orderby’ => rand, // ここでエラーが出ております。
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) {
    $my_query->the_post();
    echo get_template_part(‘related_items’);
    }
    wp_reset_query();
    }
    }
    }

    長くなりましたが、ご協力宜しくお願い致します。

    'orderby' => rand,でエラーが出ているようですが、PHPでは文字列はクォーテーションマーク(‘か”のどちらか)で囲ってやる必要があります。ですので、
    'orderby' => 'rand,'とすればいいのではないでしょうか。

    モデレーター Seisuke Kuraishi

    (@tenpura)

    たぶんこちらは解決済みですね。ステータスを変えておきます。

4件の返信を表示中 - 1 - 4件目 (全4件中)
  • トピック「wp_register_script で JSファイルを読み込んだ際、画面が白くなります。」には新たに返信することはできません。