Pages, Custom Posts & Custom Taxonomy defining slug structure

All of the cases you describe are handled by the post type archive, post type single, and taxonomy term archive pages that are all automatically generated (depending on arguments) when you register your post type and taxonomy. function wpd_add_custom_types() { // register fruit post type $args = array( ‘public’ => true, ‘label’ => ‘Fruit’, ‘has_archive’ … Read more

working Custom Post Type and Widget code no longer works when moved from functions.php to plugin

If all you want is for your plugin to work, simply replace register_activation_hook( __FILE__, ‘activate_my_careers’ ); with add_action( ‘plugins_loaded’, ‘activate_my_careers’ ); If you want to understand why your new plugin isn’t working, then you need to understand WordPress hooks. I would encourage you to carefully read the WordPress Plugin API. The first hook available to … Read more

how do i create a specific handler for a url?

You could use the parse_request hook. For example: add_action( ‘parse_request’, function ( $wp ) { // Run your actions only if the current request path is exactly ‘image-generator’ // as in https://example.com/image-generator if the site URL is https://example.com if ( ‘image-generator’ === $wp->request ) { $a = $_GET[‘a’]; $b = $_GET[‘b’]; $etc=”etc”; // … your … Read more

How to automatically apply a password to all posts within a custom post type

If you want to make all the posts for a post type password protected with the same password then you can do run an update query like below to make this happen. Use the following code in the active theme’s functions.php file. global $wpdb; $wpdb->update( $wpdb->prefix . ‘posts’, array( ‘post_password’ => ‘wpse’ ), // Replace … Read more

tags & categories with custom post type

change your code to this: /* Create custom post type: “Tilbud” */ register_post_type(’tilbud’, array( ‘label’ => __(‘Tilbud’), ‘singular_label’ => __(‘Tilbud’), ‘public’ => true, ‘show_ui’ => true, ‘capability_type’ => ‘post’, ‘hierarchical’ => false, ‘rewrite’ => false, ‘query_var’ => false, ‘taxonomies’ => array(‘post_tag’,’category’), ‘supports’ => array(‘title’) )); the function register_post_type takes a name of the post type … Read more

Remove tinyMCE from admin and replace with textarea

No need to reinvent the wheel – put your editor support back and tweak the settings: function wpse_199918_wp_editor_settings( $settings, $editor_id ) { if ( $editor_id === ‘content’ && get_current_screen()->post_type === ‘custom_post_type’ ) { $settings[‘tinymce’] = false; $settings[‘quicktags’] = false; $settings[‘media_buttons’] = false; } return $settings; } add_filter( ‘wp_editor_settings’, ‘wpse_199918_wp_editor_settings’, 10, 2 );