Jump to content

Recommended Posts

Well it all depends on what the function does.

 

Does it echo or return the statement as a value? Given that it does not have an echo preceding it, I am taking that it echos. And because of this you would either need to use output buffering, change the function to return a value, or add a parameter to tell it to echo it without line breaks. (via an if statement).

I'm trying to implement a php code in a Wordpress site to remove line breaks from excerpts. I suspect str_replace will work but I'm not sure how to use it with a function..

 

<?php the_excerpt(); ?>

 

i think you havta use javascript on this one. This echos it, not returns it

 

anyone have any idea?

 

 

As premiso said, it depends. If it returns the excerpt something like this will do:

 

echo str_replace("\n", '', the_excerpt());

 

If it echos the excerpt something like this will work:

 

ob_start();
the_excerpt();
echo str_replace("\n", '', ob_get_clean());

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.