Tag Info

New answers tagged

-1

Tty this one jQuery.getJSON('/latest-post-as-json/', function(data) { jQuery('#externalBlock').append('<h1>'+data.post_title+'</h1>'); jQuery('#externalBlock').append(data.post_content); //etc });


0

get_post_thumbnail_id() only returns the ID of the thumbnail. To get the actual thumbnail you could instead use get_the_post_thumbnail() You can also get the image using it´s ID, but that requires wp_get_attachment_image( get_post_thumbnail_id(), 'full' )


1

If you are uploading images the same size as the large size in your WordPress installation, then set your Large size to 0x0 in Settings -> Media or remove this line: add_image_size( 'large-size', $LARGE_SIZE, 9999 ); EDIT #1: Try to add this filter to delete the original image: add_filter('wp_generate_attachment_metadata', 'delete_fullsize_image'); ...


1

If you have a look at what next_post_link you'll see that it takes a parameter $link as the second argument: next_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ); Your parameter for this currently doesn't include the post thumbnail: _x( '%title <span class="meta-nav">&rarr;</span>', 'Next ...


0

I have added the style "background-position: center center;" and it work perfectly! So the new code will look like this: <?php global $post; $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' ); ?> <div class="mainblogwrapper" style="background-image: url(<?php echo $src[0]; ?> ) ...


0

global $wpdb; $children = get_posts('post_type=event&numberposts=1'); foreach ($children as $child) { $origParentID = get_post_meta($child->ID, 'mainpictureid', true); $parsed_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), 'http://localhost/wp-content/uploads/2015/08/'.$origParentID.'.jpg' ); $attachment = $wpdb->get_col( ...


0

Use this plugin. I found it after one search on google https://wordpress.org/plugins/dynamic-featured-image/


1

I found that what was causing this issue was a plugin I had enabled that was supposed to handle retina images called WP Retina 2X. I disabled the plugin and it immediately fixed the issue.


0

So, I finally noticed that what I was doing, was returning an array, and that I needed the [0] of that array. The code is on the ugly side, but it works. <?php $thumb_id = get_post_thumbnail_id(); $small_screen = wp_get_attachment_image_src($thumb_id,'small-screen', true); $medium_screen = ...


0

It happened to me when I introduced new custom image sizes and did not regenerate the thumbnails. It seems that WP searches for the proper thumbnail, and when it is not found, has some problem in calculating the proper size.


1

It's only a guess, but it's also most probable cause... When you upload an image to WP, some metadata is generated and stored in database. This metadata contains such info like name, path and size of the image (to be more precise - paths and sizes of all created images based on uploaded one). And... This metadata is stored as serialized array. When the ...


0

You can try this function, in your functions.php file. // automatically retrieve the first image from posts function get_first_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all( '/<img .+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches ); $first_img = ...



Top 50 recent answers are included