Title: Different plugin methods on different posts (by category)
Last modified: August 19, 2016

---

# Different plugin methods on different posts (by category)

 *  [tomgf](https://wordpress.org/support/users/tomgf/)
 * (@tomgf)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/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).
 * Suggestions…?

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

## Tags

 * [classes](https://wordpress.org/support/topic-tag/classes/)
 * [methods](https://wordpress.org/support/topic-tag/methods/)

 * 0 replies
 * 1 participant
 * Last reply from: [tomgf](https://wordpress.org/support/users/tomgf/)
 * Last activity: [17 years, 6 months ago](https://wordpress.org/support/topic/different-plugin-methods-on-different-posts-by-category/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
