Can you use the __call PHP class functionality?
http://www.php.net/manual/en/language.oop5.overloading.php#object.call
You could use __call in your class and call your function for grabbing the page types and check them against the $name (first) argument and running custom code against it.
For instance:
__call ($name, $args) {
$types = array ('type_a', 'type_b', 'type_c');
if (in_array($name, $types) {
// custom code
}
}
UPDATE: Response to gist.
So using __call as a method on your class, on line 90 of your gist, you would use:
$this->$slug();
Related Posts:
- Order by & include array by specific post ids
- Get list of all registered post types slugs
- Limit the post for differents custom post type in the same wp_query
- array_pop() expects array, boolean given for $event_type_term ->slug
- Save custom post type in different table
- Automatically adding meta data to posts or multiple query help
- Create a post in custom post type using field in registration form after users submit form
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- Save an array from drop-down in custom meta box
- How to store multiple values in 1 meta_key with radio input?
- Display a CPT based on a metabox selection
- Display post content with respect to its title?
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- Limit the post for differents custom post type in the same wp_query
- Custom Post Types — $args vs. labels array
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Add first letter of titles to array, then compare arrays
- Query Custom Post Types with checkboxes
- Create Array from custom post type to display a slider
- Inefficient Query Confusion
- Querying multiple values from a single key
- Check if user has comment on current post
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- How do I disply an array inside a custom post type?
- Custom Post Type Field Array parsing [closed]
- Getting custom post types to properly display alphabetically
- How can I loop at a Specific Taxonomy from a custom post type?
- Update value inside array update_post_meta
- Custom archive page for custom taxonomy and pagination issue
- Get an array of the number of post per year of a custom post type (WordPress)
- Query when is one or several values
- Staggering featured post using ‘sticky’
- If custom taxonomy exist on post?
- Convert Custom Post Data to Javascript Array for Autocomplete
- Trying to get custom post type attachment images to function in indexed array
- CPT and metabox: create multi checkbox by using array?
- Pulling in Related Posts based on Post Type array
- WordPress custom field images not getting inserted into array
- Meta-Box to add multiple items one at a time and on publish save all
- Custom Post Type Author Array Problem
- taxonomy terms array not working
- Display custom posts in checkbox list
- posting twice from an array?
- Display custom post type attached media file sizes
- post__in select all custom posts and not the selected array of ids
- Taxonomy term in permalink
- Loading Custom Post Type Events into jQuery-based FullCalendar?
- get_edit_post_link() not working as expected when passed id in plugin
- Custom Post Type – Same Post Name, Different Post Type
- Custom Post Type ‘hierarchical’ Help!
- convert Custom Fields Option-Values to Tags/Taxonomy
- How to display recent posts added in custom post types
- Dynamic iCal generator outside/inside wordpress
- Display custom post types with custom date field value (before today) & order by custom date field
- How to have the right design for a custom post type without accessing themes
- Passing parameters to WordPress static front page
- Dynamic Custom Post Type Plugin
- How to display custom post types using single-[post_type] and archive-[post-type]?
- Remove All, Published and Trashed Post Views in Custom Post Type
- How can I filter by taxonomy on a custom post type’s page?
- Using pre_get_posts to filter one loop in a multiloop archive
- Displaying Posts of a Custom Type
- Conditional Query of Custom Post Type and custom taxonomy
- Getting template_include to work when allow_url_include is off?
- How to target a specific custom post type post and its all children and grandchildren?
- Custom Post Type Video – Online/Offline
- Suggested Post and Taxonomy structure
- remove base slug from hierarchical custom post type
- Use custom walker to add taxonomy terms to main nav menu
- frontend image post uploader
- Permalink misbehaving in Custom Post Types
- How to group search results by post type and only if post type result is not empty?
- WordPress hook which triggers on post import
- Allow contributor to edit own posts after published, without plugin
- Show current user posts in custom post type query
- Custom taxonomy template shows 404 Error
- Custom post type in Custom widget – $listItem
- Get all metadata for a given custom post type
- Saving custom post in custom form
- Advanced custom field – posted fields from custom post type
- Change search query in wordpress custom post type
- How to make comments for custom post type best way
- CPT requires manage_options and edit_posts for some reason
- Updating a custom post status after an expiry date rather than trashing it
- Display custom post types in dropdown with option “all”
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Custom Post Type / Taxonomy / Term – what template to use to avoid 404-page?
- How to get post detail based on URL of the post
- Display relationship between posts
- Event Manager: Events Deleted are still in DB as published but hidden in admin
- WordPress custom post type rewrite rule matches all pages returning 404
- Issue on Counting CPT’s Under Taxonomy Term
- Adding multiple real estate properties to back end
- Manage theme related custom posts
- Buddypress: Display multiple custom post types on member’s profile
- WordPress show custom post type on homepage
- How to make a template for a specific post of a custom post type?
- Hierarchical Custom Post Types
- ACF select box css color change
- Custom slugs with dates & IDs on Custom Post Type