How to display only subcategory

The easiest way to do this would be to use wp_list_categories instead. It has depth parameter which will do exactly what you want (you can use custom walker class, if you need different output than default one). Another way would be to write your own code (but it won’t be a beautiful one). You can … Read more

Removing customise fields during plugin uninstallation

The Plugin API has hooks for that: You can use register_deactivation_hook to run a function when the plugin is deactivated. For uninstall, you have two options. Either register_uninstall_hook or add a file called uninstall.php in your plugin folder. I would not recommend delete plugin options on plugin deactivation though, the user might not know that … Read more

Use wordpress functions in another PHP file

You must put your gallery.php in the same theme folder, where the theme’s functions.php resides. Then add a single line in functions.php: get_template_part(‘gallery’,”); It’ll include the gallery.php file into functions.php and gallery.php will behave like functions.php. So, you have to keep in mind that, functions.php file is a file for WordPress and PHP functions. So … Read more

How make a php script run only with wp-cron

WP_Cron isn’t a real cron scheduler. What it does is schedule events, mark when they should be run, and wait for page traffic. When the site is loaded, it checks to see if any of these tasks need to be run (i.e. the time they were scheduled for has passed) and runs them. So you … Read more

How to save post change url youtube link?

I think you want to change default video width. You can change default embed video width and height by embed_defaults filter. add_filter(’embed_defaults’, ‘ravs_embed_defaults’); function ravs_embed_defaults($embed_size) { if (is_single()) { // Conditionally set max height and width $embed_size[‘width’] = 640; $embed_size[‘height’] = 600; } else { // Default values $embed_size[‘width’] = 460; $embed_size[‘height’] = 600; } … Read more

include any plugin within other plugin or use other plugin within other

The first plugin, the base, calls do_action() or apply_filters(). The second plugin, the one relying on the the first, uses add_action() or add_filter(). Basic example Base plugin <?php # -*- coding: utf-8 -*- /** * Plugin Name: Base * Plugin URI: http://wordpress.stackexchange.com/q/112075 */ class Plugin_Base { public function __construct() { add_action( ‘wp_loaded’, array ( $this, … Read more

How can I change a plugin’s URL?

For changing the slug, replace the line: ‘rewrite’ => true, at otw-portfolio-light.php inside $args = (…..); for register_post_type( ‘otw-portfolio’, $args ); with: ‘rewrite’ => array(‘slug’ => ‘new-slug’), note: this will be overridden on plugin update additional you might have to go to Dashboard > Settings > Permalinks and save to make changes appear