wp_nav_menu sort order?

I just found this handy little function that ads the ability to reverse the menu output order. it might come in handy: /** * Enables a ‘reverse’ option for wp_nav_menu to reverse the order of menu * items. Usage: * * wp_nav_menu(array(‘reverse’ => TRUE, …)); */ function my_reverse_nav_menu($menu, $args) { if (isset($args->reverse) && $args->reverse) { … Read more

How to wrap the widget content with a div or get the widget title outside?

this is the solution to wrap the content after the title like this ‘before_widget’ => ‘<li>’, ‘after_widget’ => ‘</div></li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2><div class=”widgetcontent”>’ ); ?> the important markup is the <div class=”widgetcontent>” in the after_title, and the closing </div> in the after_widget, this will result in this html markup: <ul> <li> … Read more

How to change admin bar color scheme in MP6 / WP 3.8 front end?

At the moment (3.8) color schemes do not apply to admin bar at front end at all, even if user is logged in and has non-default scheme selected. The shortest way would probably be to force enqueue color scheme at front end: add_action( ‘wp_enqueue_scripts’, function () { wp_enqueue_style( ‘color-admin-bar’, admin_url( ‘/css/colors/coffee/colors.min.css’ ), array( ‘admin-bar’ ) … Read more

Is it possible to manipulate the list of page templates?

The workhorse is WP_Theme::get_page_templates() (wrapped by the helper function get_page_templates()). If you check out the source, you’ll see: /** * Filter list of page templates for a theme. * * @since 3.9.0 * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * * @param array $page_templates Array of page templates. Keys are … Read more

Different ways to display title

The second form can be handy too: We can also use the third parameter: the_title( $before, $after, $echo ); to assign the title to a variable. Here’s an example: $title = the_title( ‘<h1 class=”entry-title”>’, ‘</h1>’, false ); This can also help reducing the use of <?php ?> delimiters. Here’s an example from the Twenty Fifteen … Read more

Modular theme settings

If a user can not change them then they are not options, they are constants. Declare them using const in your maim theme file (probably functions.php but any other files that is being always loaded will do), and use them wherever you have use the “options” array now. If you want to control it without … Read more