How to resize WordPress images on upload to specific height and width without cropping it

WordPress’s image resizing does not artwork your image onto a canvas, it just resizes mages to fit, cropping if you tell it to. add_image_size(‘contained-image’, 300, 400); will get you the image size you want, but not letterboxed. Images will be resized to fit tightly within a 300×400 rectangle. However they won’t be padded out to … Read more

Theme logo metadata into template file

Ends up that “alt” is not stored in wp_get_attachment_metadata so I pulled it from the post meta: $custom_logo_id = get_theme_mod(‘custom_logo’); if ($custom_logo_id) { $image = wp_get_attachment_image_src($custom_logo_id, ‘full’); $meta = wp_get_attachment_metadata($custom_logo_id); **$alt_text = get_post_meta($custom_logo_id, ‘_wp_attachment_image_alt’, true);** echo ‘<img src=”‘ . $image[0] . ‘” alt=”‘ . $alt_text . ‘” width=”‘ . $meta[‘width’] . ‘” height=”‘ . $meta[‘height’] … Read more

Why Tags don’t appear in my page?

Run a loop to output your tags: $posttags = get_the_tags($post->ID); if ($posttags) { foreach($posttags as $tag) { echo ‘<a href=”‘.get_tag_link($tag->term_id).'” title=”‘.$tag->name.'”>’. $tag->name .'</a>’; } } You don’t have to provide $post->ID if you are using this inside a loop.

how do i develop a global nav and local nav to be wordpress dynamic?

WordPress calls these Navigation Menus. There are a few steps: Set up a child theme, if you aren’t already using one. That way your changes won’t be lost when the main theme is updated. Register the menu – in your child theme’s functions.php file, function mythemeslug_register_custom_menu() { register_nav_menu(‘topnav’, __(‘Top Nav’)); } add_action(‘init’, ‘mythemeslug_register_custom_menu’); Call the … Read more