How to add custom content template part for a custom post type on main query using a plugin

Background Unfortunately get_template_part() function doesn’t have any suitable filter to achieve what you want. It’s possible to use the get_template_part_{$slug} action hook to inject template parts, however, without any change to your theme or a child theme, the original template part will be added anyway. So this way you’ll not be able to replace existing … Read more

Any examples of adding custom fields to the category editor?

No. You have to use wp_options, because you can’t create new fields in the wp_term_taxonomy table (If you do, in the next WP update you’ll loose them). So: // the option name define(‘MY_CATEGORY_FIELDS’, ‘my_category_fields_option’); // your fields (the form) add_filter(‘edit_category_form’, ‘my_category_fields’); function my_category_fields($tag) { $tag_extra_fields = get_option(MY_CATEGORY_FIELDS); ?> <table class=”form-table”> <tr class=”form-field”> <th scope=”row” valign=”top”><label … Read more

How to provide translations for a WordPress TinyMCE plugin?

Use the filter ‘mce_external_languages’. From wp-includes/class-wp-editor.php: The following filter loads external language files for TinyMCE plugins. It takes an associative array ‘plugin_name’ => ‘path’, where path is the include path to the file. The language file should follow the same format as /tinymce/langs/wp-langs.php and should define a variable $strings that holds all translated strings. When … Read more

Overwrite theme file from plugin

WordPress way (recommended): In your plugin, use the WordPress theme_file_path filter hook to change the file from the plugin. Use the following CODE in your plugin: add_filter( ‘theme_file_path’, ‘wpse_258026_modify_theme_include_file’, 20, 2 ); function wpse_258026_modify_theme_include_file( $path, $file=”” ) { if( ‘includes/example-file.php’ === $file ) { // change path here as required return plugin_dir_path( __FILE__ ) . … Read more