the_post_thumbnail fallback using hooks

you can use the post_thumbnail_html filter hook which passes 5 variables to your hooked function : $html – the Output html of the post thumbnail $post_id – the post ID. $post_thumbnail_id – the attachment id of the image $size – the size requested or default $attr – Query string or array of attributes. So something … Read more

How allow users to save list of posts?

When I am thinking about UI something like this is comming to my mind. Something similar has YouTube under the video. When user fills input and clicks enter or submit button to create list, you will send ajax request with list name and save it as a record in wp_usermeta table with meta_key _list_user_1 and … Read more

How to add default images into theme customizer image control?

Our journey starts here with the WP_Customize_Background_Image_Control class, which is a WP_Customize_Image_Control. I’d imagine offering these built-in backgrounds in a new tab alongside the existing Upload New and Uploaded tabs. There are at least two ways of achieving the following: either creating your own modified class based off of the WP_Customize_Background_Image_Control class, or altering its … Read more

Hooking new functions to actions + passing parameters

For this example lets say we have the following do_action(‘bt_custom_action’, get_the_ID(), get_the_title(), get_the_content()); The arguments that will be passed to add_action would be in this order the post id the post title the post content By default if we hook into our do_action without any arguments, like this add_action(‘bt_custom_action’, ‘bt_callback_func’); Our call back function “gets” … Read more

wp_list_categories, Add class to all list items with children

jQuery solution: You could try this if you want to use jQuery: <script> jQuery(document).ready(function($) { $(‘li.cat-item:has(ul.children)’).addClass(‘i-have-kids’); }); </script> to add the class i-have-kids to all the li parents that include the items ul.children, within the HTML generated from wp_list_categories(). Category walker solution: You could take a look at the Walker_Category class in /wp-includes/category-template.php and extend … Read more