How can we display full post on home page rather than excerpt

admin2025-06-03  2

I have a puzzle website where i am looking for the option to display full question on the home page rather than excerp. Just a note that questions are custom posts. Is there any way.

Thanks

I have a puzzle website where i am looking for the option to display full question on the home page rather than excerp. Just a note that questions are custom posts. Is there any way.

Thanks

Share Improve this question asked Feb 18, 2019 at 18:03 Avinash PatelAvinash Patel 398 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Yes, the homepage can show whatever you want it to.

First, look through your theme's files to figure out what file specifically is being used for the homepage. Sometimes it is home.php; other times front-page.php. (If your theme shows a static Page, it can also be other templates - but it doesn't sound like that's the case here.) Sometimes the file that controls the homepage includes a different file using get_template_part().

Once you determine which file is being used, you can create a Child Theme:

  1. Create a new folder in /wp-content/themes/.

  2. Create a new style.css file inside the folder and include at a minimum this comment:

    /* Theme Name: WPSE Child Template: nameofparenttheme */

You'll have to sub in "nameofparenttheme" with your actual theme. For example, if you are using the Twenty Fifteen theme as the parent, "twentyfifteen" is the template name. This tells WordPress "this is a child theme - if any files are missing here, look in the parent theme for them."

  1. Copy the file in the parent theme that controls your homepage - copy it with the same name, into your child theme folder. Change just the part where it says

the_excerpt()

to

the_content().

Keep in mind that if you are editing a template part, that will also affect other pages - wherever else that template part is called. So, if you only want to show the full post on the homepage and not elsewhere, you may instead want to copy front-page.php or home.php (the main file, not the get_template_part() and just replace the get_template_part() portion with your own code to format the post(s) however you want, including wrapper HTML and the full post content itself.

Add the following to your functions.php file:

function custom_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Change "30" to a big number so the excerpt length is increased.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748891570a314584.html

最新回复(0)