how to create category with code in wordpress using form
Since wp_create_category() is part of the admin API you can only rely it’s defined if is_admin() === true. Instead use wp_insert_term(). Check the examples in the codex.
Since wp_create_category() is part of the admin API you can only rely it’s defined if is_admin() === true. Instead use wp_insert_term(). Check the examples in the codex.
When calling add_options_page make sure to call it on the admin_menu action/event, so it’s called at the correct time add_action(‘admin_menu’, function () { add_options_page( …. ); } ); You may be able to gain further control by specifying the priority of the action in the add_action call
get_category_link only works on built-in WP Categories. It does not work on WooCommerce Product Categories. Use get_term_link instead. <a href=”https://wordpress.stackexchange.com/questions/281155/<?php echo get_term_link( $category_id,”product_cat’) ?>”> <?php echo $title; ?> </a>
Template logic is primarily controlled by template-loader.php. The part you are interested in would be get_404_template(), which passes on to generic get_query_template() with number of hooks to override the logic and result. {$type}_template (so 404_template) filter would probably do it.
By adding this to your theme functions.php file: function login_redirect( $redirect_to, $request, $user ){ return home_url(“https://wordpress.stackexchange.com/”); } add_filter( ‘login_redirect’, ‘login_redirect’, 10, 3 );
You’ll have to include and enqueue a new CSS file for your plugin on the admin side using admin_enqueue_scripts. And since you may want to load this on every page, I’d follow the first example on the Codex (pasted here): function load_custom_wp_admin_style() { wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); } … Read more
Problem 1 It doesn’t work because you’re using new_weber but you’re registering news_burner, and they aren’t the same So instead use: [news_burner] You only need a closing shortcode if it’s containing content which that plugin does not. Problem 2 Shortcodes don’t work in text widgets out of the box, you can add that functionality via … Read more
https://developer.wordpress.org/reference/functions/plugin_dir_path/ It looks like this function adds a trailing slash, so starting your string with a slash is not required try; require_once(plugin_dir_path( __FILE__ ) . ‘assets/MCAPI.class.php’);
Here is a Reference to a form field WP Nonce <form method=”post”> <!– some inputs here … –> <?php wp_nonce_field( ‘name_of_my_action’, ‘name_of_nonce_field’ ); ?> </form>
locate_template search template only in themes then to use a file outside themes, you can use the filter template_include like that add_filter(“template_include”, function ($template) { $post = get_queried_object(); if ( is_single() && (“features” === $post->post_type) ) { // absolute path to the template file $template = __DIR__ . “/../../template/my_features_template.php”; } return $template; });