Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

custom excerpt WordPress

  • SOLVED

when self-generating the excerpt, you see the "alt " for images.
How I can exclude them? and how can I prevent an automatically apply of the <p>?



I use this code to show an archive on [[LINK href="http://fdmed.org/category/noticias/"]]http://fdmed.org/category/noticias/[[/LINK]]
<div style="float:left;margin-bottom:10px;width:100%"><div class="thumblist"><?php if ( has_post_thumbnail()) : ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail('thumbnail'); ?> </a> <?php endif; ?></div><div style=""><h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> (<?php the_time('d M y') ?>)</h1><span class="linetwo"><strong><?php the_excerpt (); ?></strong></span></div></div>

Answers (4)

2011-05-11

Sébastien | French WordpressDesigner answers:

you don't want the "alt" and you don't want the <p> that's it ?


Albert Ariza comments:

yes


Albert Ariza comments:

please


Sébastien | French WordpressDesigner comments:

the "alt" will be empty if you use this code

<div style="float:left;margin-bottom:10px;width:100%"><div class="thumblist"><?php if ( has_post_thumbnail()) : ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail('thumbnail', array('alt'=>'')); ?> </a> <?php endif; ?></div><div style=""><h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> (<?php the_time('d M y') ?>)</h1><span class="linetwo"><?php the_excerpt (); ?></span></div></div>


Sébastien | French WordpressDesigner comments:

if you want absolutely not "alt" you can use this code

<?php
$url_img = get_the_post_thumbnail( $post->ID,'thumbnail', array('alt'=>'') );
$url_img = str_replace ('alt=""','',$url_img)
?>

<div style="float:left;margin-bottom:10px;width:100%"><div class="thumblist"><?php if ( has_post_thumbnail()) : ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php echo $url_img; ?> </a> <?php endif; ?></div><div style=""><h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> (<?php the_time('d M y') ?>)</h1><span class="linetwo"><?php the_excerpt (); ?></span></div></div>


Sébastien | French WordpressDesigner comments:

@ denzel > there is no image in an excerpt... is it ?


Sébastien | French WordpressDesigner comments:

and no <p> in theory...


Sébastien | French WordpressDesigner comments:

if the <p> is apply in your excerpt it's probably because there is a function to do that in your function.php
In wordpress, <p> is not apply in the excerpt.

Find "the_excerpt" in your file functions.php and paste the code here please


2011-05-11

Denzel Chia answers:

Hi,

Please try the below codes.
I had added my codes to what you posted.


<?php the_time('d M y') ?>)</h1><span class="linetwo">
<?php
$excerpt = get_the_excerpt();
$find = array("<p>","</p>","alt=''");
$excerpt = str_replace($find," ",$excerpt);
echo $excerpt;
?>
</span></div></div>


Thanks.
Denzel


Denzel Chia comments:

Yes, Sebastien, you are correct. There is no alt in excerpt. I did not see the question properly.
But make sure you don't copy anything I posted.
And there is no need for you to self promote by pointing out my mistake.

Thanks.


Denzel Chia comments:

Mr Sebastien,

Please just mind your own business.
People have freedom to post what they think is correct,
it is for the asker to judge, and not by you.
I am sure you will not like me to comment on your answer right?
Oh, by the way you forget a colon in your code. I am sure it will cause a PHP syntax error.

Thanks.

2011-05-11

Rashad Aliyev answers:

Hello,

You should look at your functions.php for changing it.

2011-05-11

Vidyut Kale answers:

Hi,

I didn't understand the problem accurately. Can you share the code that you want outputted differently?

Vidyut