New answers tagged

0 votes

Regarding to the performances, should I check if a post has a thumbnail before or after checking if is the front page (or single page, etc.)?

Tom's answer is better and more true, but I'm leaving this here because the logic might be helpful to see. In theory, all else being equal, you'd want to minimize the number of checks. The first ...
1 vote

Regarding to the performances, should I check if a post has a thumbnail before or after checking if is the front page (or single page, etc.)?

Neither, they are just as fast as each other, both are using information that has already been fetched in advance. This is micro-optimising. Functions such as is_front_page or is_singular etc etc are ...
  • 53.8k
1 vote

display WP image posts in Bootstrap 4 modal

i has trying to create a wordpress buit-in gallery and open a entire page on bostrap modal; When the modal was open the gallery show with issue. All images displayed one below another and i fugred out ...
0 votes
Accepted

the_ID & wp_get_attachment_image_src(the_ID(), "medium") blank

I changed to: $attch_id = get_post_thumbnail_id( $my_query->post->ID ); $thumbnail_arr = wp_get_attachment_image_src($attch_id, "medium"); $thumbnail = $thumbnail_arr[0]; and $...
  • 1,588
2 votes
Accepted

image_size with respect to aspect ratios

Right before image subsizes are created, there's a filter called intermediate_image_sizes_advanced that lets you modify the list of sizes. Here's code that you could expand on — right now it just ...
2 votes
Accepted

Remove default Image Sizes

To unset all default image sizes in WordPress using PHP you can use this function: add_filter( 'intermediate_image_sizes', 'remove_default_img_sizes', 10, 1); function remove_default_img_sizes( $...
  • 136
0 votes

Set Featured Image for Archive templates

YOAST! Premium does this out-of-the-box. However, I use ACF, where I can create an options page, where I added a repeater field where I can set a featured image for each post type. Then, with the ...
  • 177
0 votes

How to change post featured image using a custom field of category?

A long time ago I used code from here: https://wpforce.com/automatically-set-the-featured-image-in-wordpress/ (Looks like the post does not longer exist) and https://wpsites.net/web-design/add-default-...

Top 50 recent answers are included