How To Call Default Page Template In WordPress

Spread the love

In WordPress custom theme today we will see how to call default page in WordPress and add header and footer on default page and the_title() function will be used.

In WordPress, the page we create in a custom theme is called our default page.

What is the Default Page in WordPress

page.php is the default page in WordPress.

page.php how to show page title.

page.php To show the title of the page, we use the_title(); function

<?php the_title(); ?>
default-page
What is the Default Page in WordPress

How To Display Page Content In WordPress Custom Theme

We have two functions to display page content in WordPress custom theme, both are same but the difference between the two is that the_content() gives direct print data and get_the_content() stores your content. You have to use Echo for this, then your content will be displayed.

 <?php echo get_the_content(); ?>
<?php the_content(); ?>

In the custom theme that we create, the option of Featured Image has to be allowed. When you create your own custom theme, you have to bring the option of Featured Image.

Before

To display the featured image in the backend, a function has to be performed for this which is given below.

add_theme_support('post-thumbnails');

After

We can display selected images with two functions. In which in the first function there is a direct image display and in the second function the location of the image will be displayed, so we have to give it inside the image tag.

<?php the_post_thumbnail(); ?>

Thumbnail Image with tag

<?php the_post_thumbnail('thumbnail'); ?>
<?php the_post_thumbnail('medium'); ?>
<?php the_post_thumbnail('large'); ?>
<?php the_post_thumbnail('full'); ?>
<?php the_post_thumbnail('array(100,100)'); ?>

Get Image Path

wp_get_attachment_image_src(get_post_thumbnail_id(),'large');

Example:-

In this we will take a variable and put it in the image tag to display it.

<?php 
$futureimg = wp_get_attachment_image_src(get_post_thumbnail_id(),'large');

print_r($futureimg);
?>

Spread the love

Related Posts

Leave a Reply

Your email address will not be published.