Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've created a custom post type but now I cannot seem to figure out how to loose the image name (under the image) once a project is opened. When a project is clicked all I need it to show except for the image would be the projects name and the tweet link. Link to the test site.

In my functions.php I have:

<?php

require_once('portfolio-type.php');
add_filter('excerpt_length', 'my_excerpt_length');

function my_excerpt_length($length) {
return 25; 
}

add_filter('excerpt_more', 'new_excerpt_more');  
function new_excerpt_more($text){  

return ' ';  
}  

function portfolio_thumbnail_url($pid){
$image_id = get_post_thumbnail_id($pid);  
$image_url = wp_get_attachment_image_src($image_id,'screen-shot');  
return  $image_url[0];  
}
?>

In portfolio-type.php:

 <?php

 if ( function_exists( 'add_theme_support' ) ) { 
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 270, 170, true ); // Normal post thumbnails
add_image_size( 'screen-shot', 720, 540 ); // Full size screen
 }

 add_action('init', 'portfolio_register');  

 function portfolio_register() {  
 $args = array(  
    'label' => __('Portfolio'),  
    'singular_label' => __('Project'),  
    'public' => true,  
    'show_ui' => true,  
    'capability_type' => 'post',  
    'hierarchical' => false,  
    'rewrite' => true,  
    'supports' => array('title', 'editor', 'thumbnail')  
   );  

register_post_type( 'portfolio' , $args );  
 }  

register_taxonomy("project-type", array("portfolio"), array("hierarchical"  =>  true, "label" => "Project Types", "singular_label" => "Project Type",   "rewrite" => true));
 ?>

And finally in my index.php I have:

<div id="posts" class="row isotope">

                      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>  

                          <?php  
                              $title= str_ireplace('"', '', trim(get_the_title()));  
                              $desc= str_ireplace('"', '', trim(get_the_content()));  
                          ?>     

                          <div class="item post item span4 isotope-item">

                            <a class="project-wrp fancybox" title="<?=$title?>" rel="lightbox[work]" href="<?php print portfolio_thumbnail_url($post->ID) ?>"><div class="profile-photo"><div class="profile-icon">&#0102;</div><?php the_post_thumbnail(); ?></div>  
                            <div class="project-name"><?php echo $title; ?></div>
                            <div class="project-client"><?php echo $desc; ?></div>
                            </a>
                          </div>  
                      <?php endwhile; endif; ?>  


</div>
share|improve this question
    
What do you mean by "loose the image url"? –  s_ha_dum Jul 31 '13 at 13:55
    
When you click the project you'll see the image name right under the projects name. I'll change my question because calling it 'url' seems misleading. –  Laniakea Jul 31 '13 at 13:58

1 Answer 1

up vote 0 down vote accepted

That description-like element between the image name and the "Tweet" link looks like it is being pulled from the image alt attribute. I don't see the code that actually produces that section-- I can't find "Tweet" in what you posted. However, you might be able to get rid of that by passing an empty alt attribute like so:

the_post_thumbnail(array('230','170'),array('alt' => ''));
share|improve this answer
    
Adding 'thumbnail',array('alt' => '') to the the_post_thumbnail() in index.php made the image alt attribute disappear but for some reason the thumbnail images are now extremely foggy. –  Laniakea Jul 31 '13 at 14:25
    
The thumbnails are loading. Were you loading a different size before? Undo that and look at the source. What size image is actually loading? –  s_ha_dum Jul 31 '13 at 14:32
    
I undid it and the image size is 230px x 170px. With the 'thumbnail',array('alt' => '') the image size is 150px x 150px. –  Laniakea Jul 31 '13 at 14:40
    
Without a parameter that should default to the post thumbnail size. I don't know why it isn't, but you can pass those parameters too. Give me a second. I'll edit the answer. –  s_ha_dum Jul 31 '13 at 14:44
    
The code is missing an ' in ('230',170'). After changing that the images are okay and the alt attribute values are not showing. Many thanks s_ha_dum. –  Laniakea Jul 31 '13 at 14:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.