Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?

Unfortunately, this is not possible, at least not safe. The function wp_insert_term( $term, $taxonomy, $args = array() ) that handles the creation of taxonomies provides a few filters and hooks, but the only one before the creation of the term in the database is $term = apply_filters( ‘pre_insert_term’, $term, $taxonomy ); As you can see, … Read more

Show Meta Box On Specific Page Template

I typically use CSS and jQuery for this type of thing by hooking admin_head. This should be done client-site as a user has an option to select your template or another one after DOM load. Basically, all you do is check if the value is set for #page_template and toggle show/hide if your template is … Read more

How to create a Custom Meta Box with Name/Value Admin User Input Fields?

To help you understanding how forms work: They add to the $_POST array by a form fields name argument. <input type=”text” name=”foo” value=”Fooo!” /> would produce $_POST (array) => foo => Fooo! while <input type=”text” name=”foo[bar]” value=”Bar.” /> <input type=”text” name=”foo[baz]” value=”Baz.” /> would produce $_POST (array) => foo => (array) => bar => Bar. … Read more

Custom Post Type with Templates using Meta Boxes?

I’d recommend using the template_include filter as opposed to template_redirect, as using this hook means that you don’t redirect the user but rather just present them with the template that is requierd. add_filter(‘template_include’, ‘my_custom_template_redirect’, 99); function my_custom_template_redirect($template){ global $post; if(is_single() && ‘campaign’ == get_post_type($post)){ $page_template = get_page_template(); $new_template = locate_template( array( ‘subfolder/’ . $page_template . … Read more

custom field not saved

You are wrong, your custom field is saved but you won’t see the value pre-selected in the select box. To see it you have to set the selected attribute of the select element. You can do it easily with selected() function. You should also escape the attribute values and, in your case, use wp_reset_postdata instead … Read more

metabox select – frontend display

$change = get_post_meta($post->ID, $key, ‘resume_change_location’, true); From https://developer.wordpress.org/reference/functions/get_post_meta/ get_post_meta returns an array, not an object so you need to use $change[‘index’] The other thing is within your meta box you seem to be saving a string not an array so foreach is going to fail. The below should work… $change = get_post_meta( $post->ID, $key, ‘resume_change_location’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)