3

i want to display with help css a character with another character. In my page wordpress i have a code like this:

</span>
                <span class="address-place">
                 <?php echo the_excerpt (); ?>
                 <hr>
            </span>

This code display this line:

< p >Adult Care Home in SE Portland hiring a live-in caregiver; must speak English, be able to perform the job duties…

I want to replace < p > with another character like nothing or something else in css? I don't need to display that character in my description and i want to hide him but in css because my edit page generate < p > tags.

Display image in site: enter image description here

Thanks

4
  • 1
    Do that in PHP. It is not possible as far as I am aware with CSS (and should not be possible because CSS is just a styling language). Commented Mar 20, 2016 at 11:53
  • In try with php and doesn't work, i want css. Commented Mar 20, 2016 at 11:54
  • 1
    There's a setting in WP to turn off the p wrapping as I recall...if not there are plugins that will do it for you. - davidwalsh.name/disable-autop Commented Mar 20, 2016 at 11:56
  • 1
    Like Harry already said, it's not possible to do that in CSS. Because CSS is styling only. Commented Mar 20, 2016 at 11:57

2 Answers 2

4

CSS cannot manipulate text; it's purely a language for styling your content.

But you're using PHP — just have the PHP output whatever you wanted in the first place.

<?php echo str_replace('p>', 'whatever>', get_the_excerpt()); ?>
Sign up to request clarification or add additional context in comments.

6 Comments

Or you can do something like: preg_replace("/<\\/?p(\\s+.*?>|>)/", "", $string); Reference: stackoverflow.com/questions/1364974/…
Ok, work but just for words, if i put <?php echo str_replace('Adult', 'whatever>', get_the_excerpt()); ?> change with 'whatever' but for <p> doesn't work, i put a image in post. Thanks
str_replace() doesn't care what you're replacing — if you replace a string that's found in your content, it'll work.
I understand but he still <p>, i don't know what i miss
The <p> in your image is literally visible on the page. That wouldn't be a <p> in the markup; that would be a &lt;p&gt;.
|
1

Function the_excerpt() was echo in return, so don't use echo ( recommended to used in wp loop ). If you need to use echo, use function get_the_excerpt().

If you have issue html not decode properly, use wp_specialchars_decode. Here the options that you can achieve:

Filter the_excerpt, put this code into functions.php

    add_filter( 'the_excerpt', 'wpse221201_get_the_excerpt', 1, 1 );
    function wpse221201_get_the_excerpt( $content )
    {
        if ( ! is_admin() )
            return wp_specialchars_decode( $content );

         return $content;
    }

Or direct decode into function

echo wp_specialchars_decode( get_the_excerpt() );

1 Comment

Thanks, that help me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.