Display posts for a single post format

The post format taxonomy: The post format is a default taxonomy, registered with: register_taxonomy( ‘post_format’, ‘post’, array( ‘public’ => true, ‘hierarchical’ => false, ‘labels’ => array( ‘name’ => _x( ‘Format’, ‘post format’ ), ‘singular_name’ => _x( ‘Format’, ‘post format’ ), ), ‘query_var’ => true, ‘rewrite’ => $rewrite[‘post_format’], ‘show_ui’ => false, ‘_builtin’ => true, ‘show_in_nav_menus’ => … Read more

How to call plugin path in JS?

Use wp_localize_script() to pass any kind of data to your loaded scripts, in this case we need plugins_url(): wp_enqueue_script(‘my-script’, get_stylesheet_directory_uri() . ‘/js/my-script.js’); wp_localize_script(‘my-script’, ‘myScript’, array( ‘pluginsUrl’ => plugins_url(), )); Now you will have access to myScript.pluginsUrl in your script file: var href = myScript.pluginsUrl + ‘/path/to/resource’;

Which method is best to enqueue scripts

Always use the built-in versions. Don’t waste time with old WordPress installations – other plugins will break there too. See wp-includes/script-loader.php for the list of available files. Quite a lot. 🙂 And avoid remote resources. Some (Google) fail to send the scripts gzip compressed to all supporting browsers, others may not be reliable enough. There … Read more

How do I ‘rebuild’ the WordPress Media library after transfer to new host?

There’s a few plugins to fix this, but basically it your database still references the images to be “oldsite.com/wp-content/uploads/” and you need it to be “newsite.com/wp-content/uploads” So you have to change all old references. You could use SQL: UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite.com’, ‘http://www.newsite.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’; UPDATE … Read more

How to display a raw HTML page (bypassing WordPress theme, scripts, etc)

If you’re willing to create a child theme and put your PHP files in there, this approach is relatively clean. For each file, create a rewrite rule where you specify the path you want to use and the filename that should load. In the example below, /custom-path/ loads custom-file.php from the root of your child … Read more

Show current navigation path from menu

The best way would be to use wp_nav_menu with a custom walker. Prerequisites: Registered theme location Menu saved to that theme location Useage Wherever you want the breadcrumbs (for theme location ‘primary’): <?php wp_nav_menu( array( ‘container’ => ‘none’, ‘theme_location’ => ‘primary’, ‘walker’=> new SH_BreadCrumbWalker, ‘items_wrap’ => ‘<div id=”breadcrumb-%1$s” class=”%2$s”>%3$s</div>’ ) ); ?> The custom walker … Read more