Menu fallback “menu_class” rendering a “div” instead of a “ul”

First, I think you’re confusing the wp_nav_menu() args. The ‘menu_class’ parameter defines the class added to the menu element, which by default is <ul>, as per the ‘items_wrap’ parameter. The default ‘menu_class’ is ‘menu’, which results in <ul class=”menu”>. The real issue is actually the fallback_cb – the callback used when no menu is defined … Read more

Get current page_id before loop, in functions.php

I’m pretty sure you try to use this conditional tags to early, so they don’t work. From Codex: Warning: You can only use conditional query tags after the posts_selection action hook in WordPress (the wp action hook is the first one through which you can use these conditionals). For themes, this means the conditional tag … Read more

Load parent theme files before child theme functions.php

The functions.php file executes at plugins_loaded, with the Child Theme functions.php executing before the Parent Theme functions.php. That means that, in order to load functional sub-files in the Child Theme after the Parent Theme functions.php executes, you simply need to hook your include() calls after plugins_loaded. A usually safe action for such purposes is after_setup_theme: … Read more

how to edit functions.php in a child theme

Nearly all functions in esplanade can be overwritten in a child theme. Take the esplanade_admin_header_style() function for instance. Just before that function is the following line of code if ( ! function_exists( ‘esplanade_admin_header_style’ ) ) : . The important part here is if ( ! function_exists()): This means that the function it calls can be … Read more

Sanitize slug title

If you a look at the source you’ll see it’s because the sanitize_title filter fires after remove_accents() is called by sanitize_title(). It does however, pass the raw title as the second argument so you can perform any substitutions on the raw title, apply remove_accents() and return it: function wpsesanitize_title_extra( $title, $raw_title, $context ) { $new_title … Read more

Print Post Parent Title

You can just add a check: if ( ! empty ( $post->post_parent ) ) { $parent_title = get_the_title($post->post_parent); echo “<h1>$parent_title</h1>”; } or use setup_postdata(): setup_postdata( $post->post_parent ); the_title( /* arguments here*/ ); wp_reset_postdata();

How to hide, and not to remove the attributes metabox?

The get_hidden_meta_boxes function (source link) provides two filters that you can use to hide the meta box. (Pick just one of them.) The first is default_hidden_meta_boxes (source), adding the metabox to the $hidden array will hide the metabox by default, but the user can select the screen options tab and choose to enable it. The … Read more