最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far