• The problem is this simple: it doesn’t work. The code is:

    /** custom post types */
    function create_post_type() {
      //projects
      register_post_type( 'project',
        array(
          'labels' => array(
            'name' => __( 'Projects' ),
            'singular_name' => __( 'Project' )
          ),
          'public' => true,
          'hierarchical' => true,
          'supports' => array('title','editor','thumbnail','custom-fields','page-attributes')
        )
      );
    }
    add_action( 'init', 'create_post_type' );
    
    /** scripts */
    function my_init_method() {
        if(is_singular('project')) {
            wp_deregister_script( 'jquery-topup' );
            wp_register_script( 'jquery-topup', 'http://gettopup.com/releases/latest/top_up-min.js');
            wp_enqueue_script( 'jquery-topup' );
        }
    }    
    
    add_action('init', 'my_init_method');

    When I render a single post of type project, the script is not called, whereas if I set the if(true) it does appear. Even the is_singular() doesn’t render in single pages.

    Any known issue?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Wild guess: do you need to declare global $wpdb; in your function?

    Thread Starter Naoise Golden Santos

    (@ngolden)

    didn’t work. by declare you mean just putting $wpdb; somewhere right? also tried global $wpdb; but no.

    It’s strange because ten lines down it does work, it may have to do with the add_action('init', 'my_init_method'); function…

    anyways, I ended up installing TopUp Plus plugin that got that part of the job done.

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘is_singular() not working’ is closed to new replies.