How to add excerpt on a Page in WordPress without plugin

To add an excerpt field in WordPress Pages like we have in Posts, just paste the following code to your functions.php and have fun !!

add_post_type_support( 'page', 'excerpt' );

Get Image from Post or Page

Add the following function in function.php which is present at the root of theme folder.

function catch_that_image()
{
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=['"]([^'"]+)['"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];

if(empty($first_img))
{ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;
}

Just call the function catch_that_image(), wherever you need to get the image from the article.
e.g.

<img src="<?php echo catch_that_image();?>" width="75" height="75" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" align="left" hspace="5" />

Difference Between Posts and Pages in WordPress

Often WordPress beginners get confused between posts and pages. By default, WordPress comes with two content types, posts and pages. As a beginner, you are probably wondering what is the difference between them? It seems to have similar fields in the dashboard. It seems to look the same on the website. Why do I need both? When should I use posts? When should I use pages? In this article, we will explain the difference between posts vs. pages in WordPress.

Posts

If you are using WordPress as a blog, then you will end up using posts for majority of your site’s content. Posts are content entries listed in reverse chronological order on your blog’s home page. Due to their reverse chronological order, your posts are meant to be timely. Older posts are archived based on month and year. As the post gets older, the deeper the user has to dig to find it. You have the option to organize your posts based on categories and tags.

Because WordPress posts are published with time and date in mind, they are syndicated through the RSS feeds. This allows your readers to be notified of the most recent post update via RSS feeds. Bloggers can use the RSS feeds to deliver email broadcasts.

Posts encourage conversation. They have a built-in commenting feature that allows users to comment on a particular topic. You can go to your Settings » Discussion to turn off comments on older posts if you like. Continue reading