Support » Plugins » Different plugin methods on different posts (by category)

  • I am developing a plugin using this structure:

    if( !class_exists( 'My_Plugin' ) ) {
      class My_Plugin {
      // Methods
    if( class_exists( 'My_Plugin' ) ) {
      $my_objecct = new My_Plugin();
    if ( isset($myobject) ) {
      // Filters & Hooks

    I want is to add an extra methods (only on some cases) to the main class, like this:

    if ( class_exists( 'My_Plugin' ) && !class_exists( 'My_Plugin_Extends' ) ) {
      class My_Plugin_Extends extends My_Plugin {
      // Other methods

    I am trying to verify on which context I am in order to use $my_objecct = new My_Plugin(); or $my_objecct = new My_Plugin_Extends(); but at the plugin loading moment it seems to be that I don’t have much information yet… ($post or $wp_query globals are empty). I would like to check if the post is on a given category (so I need the extra methods).


  • The topic ‘Different plugin methods on different posts (by category)’ is closed to new replies.