php - How to show only the date, the title and a litle "summary" of my WordPress post in my custom theme? -
I am very new to the development of WordPress theme and I doubt about how posts are displayed in a post. .
I have this page from an old custom legacy blog that I am rebuilding using WordPress:
As you can see in this page, the following structure Some posts are presented using: Date < Short summary
followed by Post title and After that I want to do in WordPress.
So I have created this page which shows the list of posts:
As you can see in this page, the posts are shown (formatting is terrible because I used to be old The post from the website is imported but I will work on it for the second time)
The main problem is that if the post is too long, it shows all its contents.
This is the code for this page ( category.php ):
& lt ;? Php get_header (); ? & Gt; & Lt ;! - Contain (giglia) - & gt; & Lt; Div class = "container" & gt; & Lt ;! - Lead attendee - & gt; & Lt; Section id = "presentazione" & gt; & Lt; Div class = "row" & gt; & Lt; Div class = "col-sm-12" & gt; & Lt ;! - & lt; H1 class = "text-center" & gt; & Lt; Small & gt; Assosizon per la broken broken Derry Umani del Popolo Arrito & lt; / Small> & Lt; / H1> - & gt; & Lt; H1 class = "text-center title" & gt; Tatola dei Derry Umani del Popolo Arrito for Escosijone & lt; / H1> & Lt; H1 class = "text-center leadTitle" & gt; Association of Defense of the Human Rights of the Eritrean People & lt; / H1> & Lt ;! - & lt; P class = "lead text-center" & gt; Association of Defense of the Human Rights of the Erythrone People & lt; / P & gt; - & gt; & Lt; / Div & gt; & Lt ;! - /.col-sm-12 - & gt; & Lt; / Div & gt; & Lt ;! - /.row - & gt; & Lt; / Section & gt; & Lt ;! - / section presentazione - & gt; & Lt ;! - Project in development - & gt; & Lt; Header class = "header-szone" & gt; & Lt; H2 & gt; Ultimatum Artikoli & lt; / H2 & gt; & Lt; / Header & gt; By & lt;? Get the word using slug and tag classification $ word = get_term_by ('slug', 'featured', 'post_tag'); // term_id for tag_ not_in query_posts (array ('tag__ not_in' = & gt; array ($ word- & gt; word_id));); ? & Gt; & Lt ;? Php if (have_posts ()): // start the loop while (is_pause ()): the_post (); / * * Include post format-specific templates for content If you want to use it in a child subject, then content -___ Include a file named Php * (where ___ is a post format) and it will be used instead. * / Get_template_part ('content', get_post_format ()); Endwhile; Else: // If there is no content, then include the "No posts found" template. Get_template_part ('content', 'none'); end if; ? & Gt; & Lt; / Section & gt; & Lt; / Div & gt; & Lt ;? Php get_footer (); ? & Gt;
So what I have to do, for each post, the loop only shows the beginning of my date, title and beginning (for example, the number of a particular character).
What can I do to get this result?
Tnx
First you should start reading, in this way you know How WordPress Works
Now, the category.php template is trying to find another template with this template:
get_template_part ("content", get_post_format ());
This code is looking for content-post format.php, if that file does not exist, then WordPress looks for autocomplete.php and that file works for you To do.
You must get this file and you use the following function
the_excerpt (); Get_the_date (); Now if you want to control the size of fraction, you can use this function inside the function.fp. function custom_excerpt_length (
$ length) {20 returns; } Add_filter ('excerpt_length', 'custom_excerpt_length', 999);
Comments
Post a Comment