I am developing web site by wordpress in case my problem I want to remove h1 and h2 tag in from main page. I want to get only child p tag by get_the_content()

<p id="main">
  echo wp_trim_words(get_the_content(),20, '...' );  ?>

Main Page get the content from this page

<h1 class="entry-title">Set and Furniture Design</h1>
<h2 class="green-pd">Set Design</h2>
<p id="para">A Bachelor pad was to be designed for a cookery show called 'Cook na kaho' for the Star One TV channel. Props for same were purchased from various home stores and the set was installed with in four days of starting work.</p>
<h2 class="green-pd">Furniture Design</h2>
<p>The 600mm X 1500mm rectangular centre table used the Indian screen called jaaliwork as supports to the table top for breaking the monotony of solidity and straight lines.</p>

Please help me

Thank you...


Wordpress function get_the_content automatically remove html tags from the content, So fetch only p tag content is not possible with using this function. you can use post excerpt to fulfill your requirement.

Each post has section in admin called Excerpt It you are unable to see the section in the admin please check screen option while editing the post

$my_excerpt = get_the_excerpt();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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