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

WordPress add post format support not working

Add this to your child theme which over-rides what your parent theme supports. Post Formats for Posts add_action( ‘after_setup_theme’, ‘wpsites_child_theme_posts_formats’, 11 ); function wpsites_child_theme_posts_formats(){ add_theme_support( ‘post-formats’, array( ‘aside’, ‘audio’, ‘chat’, ‘gallery’, ‘image’, ‘link’, ‘quote’, ‘status’, ‘video’, ) ); } And here’s the result tested on the Twenty Twelve default theme. You can also use the … Read more

Getting the author name on author archive page

I don’t know what are you trying to do with if-else statement, but to display author name with their published post link use this code: <span>Article posted by <?php the_author_posts_link(); ?></span> Tweak it according to your need. One more thing: You need to call the_author_posts_link() function within the while loop (Yes, the same while loop, … Read more

Calling directories to load in wordpress

I usually split my theme’s functions into several files as well, and include those in my functions.php, like so: // load helper functions require_once get_stylesheet_directory().’/inc/helper-functions.php’; // load admin functions if (is_admin()) require_once get_stylesheet_directory().’/inc/admin-functions.php’; // load theme functions require_once get_stylesheet_directory().’/inc/theme-functions.php’; // load post functions require_once get_stylesheet_directory().’/inc/post-functions.php’; // load WooCommerce functions if (in_array(‘woocommerce/woocommerce.php’, apply_filters(‘active_plugins’, get_option(‘active_plugins’)))) require_once get_stylesheet_directory().’/inc/woocommerce-functions.php’; … Read more

PHP help get_template_directory + PHP include

get_template_directory() and get_stylesheet_directory() both pull form the wp-content/themes directory. The difference being that the former always pulls from the parent theme directory. Neither take parameters, so you just concatenate the rest of the path to the string returned from the appropriate function. That is: include get_template_directory().’/inc/social.php’; If your file is not in your theme directory, … Read more

Link posts to pages for breadcrumbs

You need to go and have a look at template hierarchy for custom post types. I believe your custom post type is tennis. So you would make a copy of your theme’s archive.php template and call it archive-tennis.php You can now style that template to your liking. Just remember, you don’t need to add or … Read more

I want to select the from values from database in WordPress? [closed]

Read the wpdb docs and don’t forget to protect your query: global $wpdb; $table_name = $wpdb->prefix . “item”; $login_name = sanitize_user( $_POST[‘login_name’] ); //assuming you’re dealing with username $prepare = $wpdb->prepare( “SELECT * FROM $table_name WHERE uname = %s”, $login_name ); $myrows = $wpdb->get_results( $prepare ); //output results echo ‘<pre>’ . print_r( $myrows, true ) … Read more