Our Directory platform is based on three plugins and a parent theme:
- Tevolution(plugin)
- Tevolution directory(plugin)
- Tevolution Location Manager(plugin)
- Directory(theme)
Before creating a plugin or child theme for Directory platform you must know what WordPress hooks are. We have extensively used Action and Filters in Directory platform so the best way to extend the core functionality is using these already available hooks.
What are hooks?
Hooks are defined in specific places throughout each theme so that your plugins or custom functions can ‘hook into’ Directory without modifying the core code.
Hooks in plugin :
add_action ( ‘hook_name’, ‘your_function_name’, [priority], [accepted_args] );
where:
- hook_name – The name of an action hook provided by AppThemes, that tells what event your function should be associated with.
- your_function_name – The name of the function that you want to be executed following the event specified by hook_name. This can be a standard php function, a function present in the AppThemes core, or a function defined by you in the plugin file
- priority – An optional integer argument that can be used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
- accepted_args – An optional integer argument defining how many arguments your function can accept (default 1), useful because some hooks can pass more than one argument to your function.
We recommend you to go through this detailed explanation along with examples to know more about how you can use extend Directory platform with hooks. Also checkout developer documentation section on this page to see the list of hooks used in Directory platform, we have even added some examples there on how you can use these hooks to extend Directory.
Some guidelines on using hooks with Directory platform
- Your Tevolution hooks must start with “tevolution” prefix.
e.g. To add an advertisement after post title.
add_action(‘templ_after_post_title’,’tevolution_advertisement’); Function tevolution_advertisement(){ Echo “Your advertisement Will be here ”; }
- You may need to add so many filters for different purpose so its better to prefix your filters to differentiate.
- Now if you want to add/change something related to Tevolution-Directory plugin first Look in to the hooks of directory. https://templatic.com/docs/list-directory-plugin-hooks/.
- Same as tevolution, your Tevolution-Directory function should have “directory” prefix. You can locate all detail page and listing page templates in template folder inside Tevolution-Directory plugin folder.
- Removing hooks
To remove some element from core Directory use remove_action in your plugin. For example,
remove_action('tmpl_related_post','related_post_by_categories');
How to create a child theme
We recommend to read this awesome tutorial on how to create a child theme on codex. This pretty much explains everything on how to get started with a child theme.
- Overwriting Template files using child theme
All core plugins have “template” folder. If you want to change the structure of specific pages then you can copy that file from plugin and place it in the child theme you are creating. For example, if you want to change the structure of listing detail page completely then take the single-listing.php file from Tevolution-Directory/templates/ and put it in root of your child theme and then start customizing it.