Help Fallback (thumbnail)

This should work global $post; $html = “”; $my_latest_posts_widget = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3 )); $html .= ‘<div id=”container_recent_posts_widget” class=”container_recent_posts_widget”>’; if( $my_latest_posts_widget->have_posts() ) : while( $my_latest_posts_widget->have_posts() ) : $my_latest_posts_widget->the_post(); $thumb = get_template_directory_uri() .’/assets/images/default-image-post-thumbnail-widget.jpg’; if ( has_post_thumbnail() ) { //override fallback image if post has any thumbnail $thumb = get_the_post_thumbnail_url(); } … Read more

How to display post title inside thumbnail?

Think this should do it… (there are hundreds of ways to achieve this) <?php // Display blog posts on any page @ https://m0n.co/l $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query(‘posts_per_page=5’ . ‘&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail … Read more

Using wp-cli and delete everypost first image

According to the WP-CLI docs for the wp search-replace command (and wp db search, for that matter), you have to pass your search string without delimiters and pass any flags separately. Instead of: wp search-replace ‘/<img[^>]+\>/i’ ” wp_posts –regex –allow-root You would use something more like this: wp search-replace ‘<img[^>]+\>’ ” wp_posts –regex –allow-root –regex-flags=”i” … Read more

Hide Featured Image box – isn’t working?

The context or the 3rd parameter of remove_meta_box() function for tags meta box and featured image meta box is side. And perfect hook to remove meta box is add_meta_boxes. So try the following code, hope it’ll work as expected. function my_remove_meta_boxes() { if ( ! current_user_can( ‘administrator’ ) ) { remove_meta_box( ‘tagsdiv-post_tag’, ‘post’, ‘side’ ); … Read more