WordPress.org

Support

Support » How-To and Troubleshooting » Remove the first line of content from posts

Remove the first line of content from posts

  • Hello everyone!

    This is the situation, I used to add an image to my posts right into the content, then I figured that I can used featured images. To not repeat the images in a post I found a code that it will scan for the first image and then ignore it from the post. but the problem is that every time I create a new post I am forced to add a first image to the post. I am looking for a piece of code that I can use that it will go post by post, scan for the first image and delete from the post. There is anyway way to do this? Any help will be appreciated!

    Thanks,

Viewing 6 replies - 1 through 6 (of 6 total)
  • I also have this question.

    I have over 500 posts, and need to delete the first line of each of them. Any way to do this without manually going in and editing them one by one?

    I thought I was the only one! Let’s hope somebody help us out!

    esmi

    @esmi

    Forum Moderator

    Is it exactly the same line in all of the posts?

    I am 99.9% sure it is. This is what it looks like:
    <p><a href="link-here"><img class="class" title="Title" src="link-here" alt="alt" width="684" height="250" /></a></p>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

    I think it will be more accurate to say that I need to scan for the first image that it is in post and just get it out of there.

    Thanks,

    My question is slightly different – it’s not the same line in all of the posts.

    You can look at this page for example: http://www.pinkfloydtabs.com/echoes-guitar-tab

    I want to delete the “Echoes – Pink Floyd” part at the beginning of the post, because I am going to do a stylized replacement for that with the usage of this: <h5><?php the_title(); ?></h5>

    So all of the posts have the “Song Title – Pink Floyd” just as text at the very beginning of each tab/post. But the “Song Title” part is different for each.

    esmi

    @esmi

    Forum Moderator

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Remove the first line of content from posts’ is closed to new replies.