Custom Yoast Breadcrumbs URL

That’s an unusual setup – Yoast usually recognizes the right permalinks. You may want to consider changing the way you set up your custom post type, so that it has the desired names and URLs to begin with. You’re likely to have two different URLs that point to the same content, which is undesirable for … Read more

Getting the comment number relative to all the post’s comments

Try the following custom Comment Walker class. The walker keep tracks for print index in a global variable named $current_comment_print_index; which is intialized in the paged_walk function. You can print global variable $current_comment_print_index to show the current printed comment number. <?php /* Plugin Name: Comment Count Walker for WPSE 20527 Author: Hameedullah Khan Author URI: … Read more

How do I remove a require_once admin panel from the parent theme from the child theme functions.php?

For cases where you want to require/include PHP files, but still allow child themes to replace those PHP files outright, then you should use the locate_template function. Example: Parent does this: locate_template( ‘admin/file.php’, true ); This finds the admin/file.php file in either the child or the parent theme, then does a require on it (that’s … Read more

WordPress redirect to landing page if not logged in

something like: if ( !in_array($GLOBALS[‘pagenow’], array(‘wp-login.php’, ‘wp-register.php’)) && !is_admin() && !is_user_logged_in() ) { wp_redirect(‘http://www.mysite.com/landingpage’, 301); exit; } should do it. see http://codex.wordpress.org/Function_Reference/is_admin & Check if wp-login is current page

queries inside of a class

class MyClass{ function __construct(){ global $wpdb; $this->db = $wpdb; } function query(){ return $this->db->query( $this->db->prepare(“INSERT INTO {$this->db->wp_competitors} (id, ield_key, field_value) VALUES ( %d, %s, %s )”, 1, $field_key, $field_value) ); } }

How to remove a metabox from menu editor page?

By inspecting the file /wp-admin/nav-menus.php we can see that these meta-boxes: are rendered with: <?php do_meta_boxes( ‘nav-menus’, ‘side’, null ); ?> The file /wp-admin/includes/nav-menu.php contains the corresponding add_meta_box() calls and from that we can construct the relevant removal code: function custom_remove() { remove_meta_box(‘nav-menu-theme-locations’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-custom-links’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-post’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-page’, ‘nav-menus’, ‘side’); remove_meta_box(‘add-category’, … Read more