0

これはプラグインのコードです:

 <?php

        function np_init() {  
            $args = array(  
                'public' => true,  
                'label' => 'Nivo Images',  
                'supports' => array(  
                    'title',  
                    'thumbnail'  
                )  
            );  
            register_post_type('np_images', $args);  
        }  
        add_action('init', 'np_init');
          function np_widget{
               add_image_size('np_widget', 180, 100, true);  
        }
        function np_function {
        add_image_size('np_function', 600, 280, true);  
      }
          ?>
    <?php
    /*
      Plugin Name: Nivo Plugin
      Description: Simple implementation of a nivo slideshow into wordpress
      Author: Ciprian Turcu
      Version: 1.0
     */
    ?>
      <?php  function np_register_scripts() {  
            if (!is_admin()) {  
                // register  
                wp_register_script('np_nivo-script', plugins_url('nivo-slider/jquery.nivo.slider.js', __FILE__), array( 'jquery' ));  
                wp_register_script('np_script', plugins_url('script.js', __FILE__));  

                // enqueue  
                wp_enqueue_script('np_nivo-script');  
                wp_enqueue_script('np_script');  
            }  
        }  

        function np_register_styles() {  
            // register  
            wp_register_style('np_styles', plugins_url('nivo-slider/nivo-slider.css', __FILE__));  
            wp_register_style('np_styles_theme', plugins_url('nivo-slider/themes/default/default.css', __FILE__));  

            // enqueue  
            wp_enqueue_style('np_styles');  
            wp_enqueue_style('np_styles_theme');  
        }  ?>

次のコード行を配置する場所がわかりません:

add_action('wp_print_scripts', 'np_register_scripts');  
add_action('wp_print_styles', 'np_register_styles');  
4

1 に答える 1

0

add_action関数の後にrightを置く必要があります。例えば:

function np_script()
{
 .....
 .....
} 
add_action('wp_print_scripts' , 'np_script');

function np_style()
{
 .....
 .....
} 
add_action('wp_print_styles' , 'np_style');
于 2012-08-23T08:14:32.987 に答える