Tag Info

New answers tagged


OK, now I can get latest post of tags. // Front end only, don't hack on the settings page if ( ! is_admin() ) { // Hook in early to modify the menu // This is before the CSS "selected" classes are calculated add_filter( 'wp_get_nav_menu_items', 'display_lasts_three_posts_for_tags_menu_item', 10, 3 ); } // Add the three last posts of a ...


Try this wp_get_attachment_image_src( $attachment_id,'full');


Facebook sharer no longer accepts custom parameters. Long story short, use a plugin like WordPress SEO to automatically add the open graph data for you.


when you upload image to WordPress you must to fill Title field. and also your theme must use default WordPress thumbnail function.


The function you are looking for is has_post_thumbnail() With this function you can check, if a featured image has been attached to a post and perform the following code: <?php if( get_field( 'photos' ) ): ?> <div class="img"> <?php echo '<a class="image" href="' . get_permalink() . '"><div class="img"><img src="' ...


You can use the wp_generate_attachment_metadata filter: function wpse_183835_to_jpeg( $meta, $post_id ) { $sizes_to_convert = array( 'thumbnail', ); $path = dirname( get_attached_file( $post_id ) ); foreach ( $sizes_to_convert as $size ) { if ( ! empty( $meta['sizes'][ $size ] ) ) { $data = $meta['sizes'][ $size ...


You need one more conditional if ( is_404() ) { // your code here } Your function: add_action( 'genesis_before_header', 'minimum_featured_image' ); function minimum_featured_image() { global $post; if ( is_home() ) { echo '<div id="featured-image-home">'; echo get_the_post_thumbnail($post->ID, 'header'); echo '</div>'; } ...


The second if statement requires it to be a post, so a 404 page won't pass. I'd re-do it like this, using elseif statements. I also changed $thumbnail->ID to $post->ID since the former was not defined. add_action( 'genesis_before_header', 'minimum_featured_image' ); function minimum_featured_image() { global $post; if ( is_home() ) { ...


First add the following code to your theme functions.php: add_image_size( 'square-150', 150, 150, true ) In sarkpress-function.php file, change this line: <?php the_post_thumbnail(); ?> to: <?php the_post_thumbnail('square-150'); ?> You would have to regenerate your images by using Regenerate Thumbnails plugin Preferences: ...


Ok I got it! Here is the code I used: add_action('publish_post', 'custom_auto_featured_image_publish_post',10,2); function custom_auto_featured_image_publish_post($post_id, $post) { // get category of post ID $cat_detail=get_the_category($post_id); $cat_name = array(); foreach($cat_detail as $cd){ $cat_name[] = $cd->cat_name; ...


hackish solution: since wordpress add a lot of classes by default to the <img>, if you don't change that behaviour by force, you can always 'inject' something via str_replace before the string class=. In code: $image = get_the_post_thumbnail( $post->ID, 'medium', array( 'class' => 'myclass' ) ); $moreattrs = 'data-fullimg= "full.jpg"'; $image ...


You can see this link. there has some example like add_action( 'after_setup_theme', 'baw_theme_setup' ); function baw_theme_setup() { add_image_size( 'category-thumb', 300 ); // 300 pixels wide (and unlimited height) add_image_size( 'homepage-thumb', 220, 180, true ); // (cropped) }

Top 50 recent answers are included