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

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

How to load jQuery in the footer – nothing works for me

You need to load your scripts in the footer so you’ll need to add them to the functions. This method works for parent themes dependent on jQuery. For child themes Change: get_template_directory_uri() To get_stylesheet_directory_uri() Example code for parent themes: function wpsites_load_scripts() { wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘wpsites_load_scripts’ … Read more

Fatal error: Cannot redeclare when switching themes

The CSS for my parent theme (core) was incorrectly formatted. The code at the top read: Theme Name: Core Theme URI: http://www.domain.co.uk Description: The core theme. Author: Squideyes Author URI: http://www.domain.co.uk Template: Core Version: 1.0.0 Tags: clean, simple, easy The Template: tag should only appear in the child theme css. This is what caused the … Read more

Make parent page only link to first subpage

class Themeslug_Page_Navigation_Walker extends Walker_Nav_Menu { function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields[‘id’]; if ( !empty( $children_elements[ $element->$id_field ] ) ) { $element->url = $children_elements[$element->$id_field][0]->url; } Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } } This did the trick.

Right way to update widget on dynamic new input field

Ok, i have solvd it, there is my updated code <?php /** * Adds TMD_Radio_Player. */ class TMD_Radio_Player extends WP_Widget { /** * Register widget with WordPress. */ function __construct() { parent::__construct( ‘tmd_radio_player’, // Base ID __(‘TMD Radio Player’, ‘text_domain’), // Name array( ‘description’ => __( ‘Menampilkan radio player’, ‘text_domain’ ), ) // Args ); … Read more