Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’

Luckily, I was facing the same issue an hour ago so I brainstormed for a long time to find a find a solution. I posted it here before seeing this: http://www.hardeepasrani.com/2015/12/using-postmessage-transport-method-for-header-image/ So instead of just using: $wp_customize->get_setting( ‘header_image’ )->transport=”postMessage”; I used: $wp_customize->get_setting( ‘header_image’ )->transport=”postMessage”; $wp_customize->get_setting( ‘header_image_data’ )->transport=”postMessage”; After that, in JS, we got the value … Read more

Use of undefined constant FS_CHMOD_DIR – assumed ‘FS_CHMOD_DIR’

It’s really quite simple. The theme author is using a constant that you can put in wp-config.php, but because you don’t use that constant, and the author never checks if it’s actually defined, the code throws a PHP warning https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions Override of default file permissions The FS_CHMOD_DIR and FS_CHMOD_FILE define statements allow override of default … Read more

How to get the name and description of a sidebar in theme?

You can use the $wp_registered_sidebars global variable. Like this: global $wp_registered_sidebars; if( is_active_sidebar( ‘activity_calendar_en’ ) ): esc_html_e( $wp_registered_sidebars[‘activity_calendar_en’][‘name’] ); dynamic_sidebar( ‘activity_calendar_en’ ); endif; If you check the WordPress core for is_registered_sidebar function, you’ll see that it’s using this global variable too: function is_registered_sidebar( $sidebar_id ) { global $wp_registered_sidebars; return isset( $wp_registered_sidebars[ $sidebar_id ] ); } … Read more

Organize functions.php

Doing this simply won’t make a significant performance difference, instead organize your customizations with clear headings so you can find and edit things faster later… in other words, organize for development in this case, not for the frontend. There are plenty of other optimizations that can be done with some research but this just isn’t … Read more

Change text of twentyseventeen_edit_link()

The twentyseventeen_edit_link() function returns an accessibility-friendly link to edit a post or page. Here is its content: function twentyseventeen_edit_link() { $link = edit_post_link( sprintf( /* translators: %s: Name of current post */ __( ‘Edit<span class=”screen-reader-text”> “%s”</span>’, ‘twentyseventeen’ ), get_the_title() ), ‘<span class=”edit-link”>’, ‘</span>’ ); return $link; } Since it doesn’t provide a hook or filter, … Read more

Return only top-level navigation items from a menu using wp_get_nav_menu_items

Let’s take a look at wp_get_nav_menu_items code reference. It takes two parameters: $menu – (int|string|WP_Term) (Required) Menu ID, slug, name, or object, $args – (array) (Optional) Arguments to pass to get_posts(). So we can use get_posts args in here… And if we want to get only top-level posts, then post_parent arg comes useful… So something … Read more