I figured it out myself and it worked. Here is the code if anyone need any help.
$the_query = new WP_Query('page_id=1') ;
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
the_title();
the_content();
the_excerpt();
}
} else {
// no posts found
}
wp_reset_postdata();
Edit:
This is working because the_content()
and the_excerpt()
have to be used within The Loop.
Related Posts:
- Problem on the_excerpt(); function
- how to include page content to specified length & then “read more” link
- Modify Ixion Theme to Include Post Excerpt On Main Page
- How can i display the content in plaintext
- Only show content before more tag
- post_content with line breaks
- Why is the_content() not displaying the content? [closed]
- Modify ‘Read more’ link adding a new class
- Get excerpt from $post->post_content
- Heartbeat API oEmbed
- limit the words in the post content and add read more link
- Apply the_content filter for specific post types only
- How to to stop html editor from addig tags to shortcodes, images, etc
- Static page homepage not showing the_content
- How to add an inline style to the tag outputted in the_content() using PHP?
- Word limit in post_content after more tag
- Is it possible to handle a specific section of a post separately?
- Is it possible to change the contents of “the_content()”?
- How to encode post content as JSON?
- How to output only the post content
- get_the_excerpt() not returning anything when post has no excerpt
- How to hide and content from auto-generated excerpts?
- How I can split text in the_content() into 2 columns?
- How to get excerpt correctly formatted
- How can I show the actual content of Posts page because the_content() is showing all blog content?
- the_content() isn’t showing content, but $post->post_content does
- Add $more_link_text parameter to the_excerpt()
- Extremely slow pageload for long post when using the_content?
- How Can A Plugin Hook Itself To the End of Every Excerpt?
- preg_replace Remove comment text in content
- How to show video from specific category on sidebar?
- tag the_content()
- How to correctly limit the content and strip HTML?
- the_excerpt(), get_the_excerpt() and the_content() all killing “the Loop”
- Content/Excerpt length control for a specific loop?
- Add span to the first letter of post
- WordPress replacing all line breaks in comments with “rn”
- Proper use of the_content filtering
- put the content of a single post into og:description
- Getting first 20 words without excerpt
- Output the_title() inside the_content()
- the_content is always surrounded by paragraphs (how to disable or remove them)?
- $content = $post->post_content; with formating
- Replace full content with an excerpt
- Filter the_content() in the Quote Post Format to Display Quotes
- Combining the_excerpt with the_content
- How to count rows of table in the_content()
- WordPress get_the_content get child element like p value
- Strip links from the_content
- Concatenate a Function to the Post Content
- How to change the position of Jetpack sharing icons? [closed]
- embed the_content
- Hook midway through the_content();?
- How do I Add HTML to the_excerpt() & the_content() Output?
- How to have a “clean” post content, for excerpt and social networks sharing
- Appending code to the_content
- Gutenberg is Adding Additional HTML Tags When Grabbing the Excerpt
- Missing content in Pages only
- Short Overview in AMP Version and Link to full article non-amp [closed]
- Changing Image Size In The Content tag
- the_content() – Getting formatted text
- limit how many words show up in the_content on index
- the_excerpt() in content.php and get_template_part() in single.php
- How can I display “read more” without any other post text?
- WordPress appends the_content filtered text inside last paragraph tag of content (rather than after it)
- Giving the_excerpt in the place of the_content?
- the_content() printing site title after page/post title and before its content
- WordPress adding content into different sections
- Excerpt is being added above the content, but it should be after it
- How to keep before/after text inline with nl2br and the_content()
- removing tags around img, iframes and also scripts
- Remove links from the_content when using filters wp_trim_excerpt
- Should I find/replace values in the_content?
- Remove images from the_content [duplicate]
- How to disable the_excerpt from one post
- How to limit the characters shown on the page – get_content
- Extract a link in the_content()
- Content DISAPPEARS when simply adding normal text for ONE POST ONLY
- How do I pull excerpts from pages?
- How do I show current post content in the header?
- has_excerpt() not working inside wp_query
- strip_tags in get_the content
- Split the_content into two parts
- first paragraph of the_content as meta description
- Searching for themes that post full article on home page by default
- Single.php the_excerpt loads same as the_content not loading read more line
- Insert div after h2 in content
- the_content() returning unexpected div wrappers
- How can I output the content of the page using this code?
- filter h1 tag to add a word at the beginning of the text
- the_content() brings the medium size image [closed]
- Why is get_the_excerpt returning full content
- How can i specify the size of the image rendered by the_content();?
- IF Inside A Function For Content Filter [closed]
- Get Content Limit?
- Append data to the_content within the database (not using filter)
- Post Format Link Validation Error
- the_content returns blank when adding SEO details
- Problem in replacing the_content with the_excerpt()
- How to add multiple the_content or something like that?