Within the loop, I want to use a variable ($number) from one of my meta fields, to pull the feature image from a different post.
EG: This works of course, getting the image from post no. 3778 :
<?php echo get_the_post_thumbnail( 3778 , 'thumbnail' ); ?>
but I need the number to be my variable, such as:
<?php echo get_the_post_thumbnail( $number , 'thumbnail' ); ?>
I’ve been at this for 2 days now… PLEASE HELP?!
]]>The main site is at dsnamerica.com/test/
One subsite example is at dsnamerica.com/test/idaho/
I can pull all content (title, post, links) and I have no problems changing or generating new permalinks. I do not think I have rewrite issue. I think the problem is in my theme’s code. This was a premium (cost bank) theme and I want to use it, but their response time is pretty bad at Magazine3 so I need help from you guys please.
I want to be able to post on the main site and sub sites, but see all of those posts on the main site’s index page. Of course I also want to see all articles published in test/idaho/ in the test/idaho site, and this is working perfectly. It’s only when I try to see an article from the Idaho subsite in the main site. I can also see the posts made in the main site just fine.
I think it’s how the theme’s code is calling the thumbnails. I’ll give you some code now since that’s what you want to see
Section of theme index.php:
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php if(get_option('thumbok')!="no"):?> <?php if( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('smblock3_block_l'); ?></a>
<?php } else { ?>
<a href="<?php the_permalink(); ?>"> <img src="<?php bloginfo('template_directory'); ?>/img/noimg.png" alt="" style="width:284px; height:190px;" /> </a><?php } ?>
<?php endif?>
<?php if(get_option('thumbok')!="yes"):?>
<?php $m_scrp = get_template_directory_uri() . '/includes/timthumb.php?';
$m_image = '';
$customfields = get_post_custom(); if (empty($customfields['image'][0])) {
$m_image = m_theme_capture_first_image(); } else { $m_image = $customfields['image'][0]; } if (empty($m_image)) { $imgpath = $m_image_def; } else {
$imgpath = $m_scrp . 'src=' . $m_image . '&w=' . 284 . '&h=' . 190 . '&zc=1'; } ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<img src="<?php echo $imgpath; ?>" alt="" /> </a>
<?php endif?>
Yup… it uses timthumb. If you’re wondering, yes, I’ve modified the $allowedSites array to include dsnamerica.com. Also, as a test I’ve also included https://dsnamerica.com, https://dsnamerica.com/idaho as well. Right now, ALLOW_EXTERNAL is also set to TRUE, but if that makes you pee your pants a little, rest assured I will put it back to false after this problem is solved.
In my functions file I’ve added some custom image sizes because you’ll notice that the home/landing/index page of dsnamerica.com/test offers a variety of thumbnail/featured image sized areas.
if( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' ); add_theme_support( 'homepostthumbnails' );
add_image_size( 'colorcontentblock4', 205, 120, true );
add_image_size( 'featbigimg', 418, 215, true );
add_image_size( 'secslider', 302, 238, true );
add_image_size( 'content2', 150, 75, true );
add_image_size( 'smblock1_block_l', 200, 150, true );
add_image_size( 'smblock1_wrap_r1', 81, 61, true );
add_image_size( 'smblock2_block_l', 328, 181, true );
add_image_size( 'smblock3_block_l', 284, 190, true );
add_image_size( 'smblock4_block_l', 99, 66, true );
add_image_size( 'smblock5_block_l', 129, 67, true );
add_image_size( 'smblock6_block_l', 138, 104, true );
add_image_size( 'sidebar-thumb', 50, 50, true );
add_image_size( 'relatedimg', 55, 55, true ); }
I have tested a great number of possible fixes. I can’t think this through anymore. But I did have a minor success by editing the index.php of the theme to use get_the_post_thumbnail() rather than has_post_thumbnail() and it is showing the thumbnails! But… they’re all the same default size (150). Here is the code I’ve edited in the slider section (same as the code I edited in the section below the slider):
<?php query_posts('showposts=5&cat='.of_get_option('example_select_categories').'&offset=0'); if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="slide slides_threewrap">
<?php if(get_option('thumbok')!="no"):?> <?php has_post_thumbnail() ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('secslider'); ?></a>
<?php if(function_exists('get_post_thumbnail_id') ) { ?>
<?php } else { ?>
<a href="<?php the_permalink(); ?>"> <img src="<?php bloginfo('template_directory'); ?>/img/noimg.png" alt=" " style="width:302px; height:238px;" /> </a><?php } ?>
<?php endif?>
<?php if(get_option('thumbok')!="yes"):?>
...blah blah, the rest is the same
Help a brother out! Could it be SWT problem? Theme code? My code? What’s the best way to fix this little/big problem?
Thanks all!
]]>I use the following code in functions.php in order to load jQuery and set variables that I need to use in my jQuery script (width and height of the post thumbnail).
<?php
if( !is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"), false, '');
wp_enqueue_script('jquery');
wp_localize_script( 'jquery', 'MyThumbSize', array( 'width' => '240px','height' => '160px' ) );
}?>
I would like to know if it is possible to automatically obtain these values from a function and what would be the syntax (Since I’m not a good coder).
I know these settings are set by the admin the dashboard under Media Settings.
]]>Any suggestions or work arounds?
]]>I’m researching the possibility of creating a plugin that would enable mass creation of posts with associated images. Is there any function that works like set_post_thumbnail()
would, if it existed? If there is no such function, can anyone point me to where I should start digging to create my own?
Thanks for any help!
]]>I can call the images using literal links but neither get_post_thumbnail nor get_the_post_thumbnail works. I had specified a number of custom sizes in functions.php, called things like product-medium, product-large, etc but even the default get_post_thumbnail() returns nothing. I’ve uploaded files to these directories and all of the folders contain the proper files.
All the images show up in the media library as being attached to specific posts–as intended–but nothing is actually displayed on the site.
Is there possibly something I’m missing in my functions.php file when specifying custom sizes? I followed the directions closely and have had no PHP errors with that.
Any suggestions would be appreciated.
]]>