WordPress Page Components

Elements that make up a page for WordPress, predefined in CMS code and represented by a function call in PHP.
Like Lego bricks, they can be assembled to form the interface chosen by the author of the theme.

Part Display Cycle

In the main cycle, a simple ticket or several or excerpts from the latest tickets are displayed.

Start of cycle
 if (have_posts()) : while (have_posts()) : the_post(); 

Displays one or more items. The number is defined in the dashboard.

End of cycle
 endwhile;  else:
_e('Sorry, no posts matched your criteria.');
endif;

_ e is a CMS function and the string in the argument is translated by the localization component.

Date

the_date('format','avant','après');

The parameters are in order:
- Display format. It depends on the country.
- is the HTML code to be placed before. Example: <h4>
- HTML code to be placed after. Example: </h4>
It is better not to specify a format that allows the user of the template to independently configure it depending on the country.

Category

the_category(','),

The arguments are in order:
- splitter. For example, comma as above. Another example: & bull; for the round.
- View: Multiple or single for category hierarchy, if any.

Author

the_author();

We add the author to the joint site, otherwise he is superfluous. This function no longer has parameters.
If the authors have different sites, the link to the profile can be replaced with a link on the author's website.

the_author_link();

Other options are described in the code.

Article Title

the_title();

It is not part of the article, but is stored in a specific field in the database .
Additional arguments:
- Before: HTML code inserted before the header, for example "h1."
- After: HTML code inserted after.

Example: the_title ("<h1>," "</h1>");

Ticket contents

the_content(__('(more...)'));

The ___ () argument is used for text displayed when content is cut. It does not appear when a page is dedicated to a single article. The text is translated automatically using the localization module.

Got feedback

comments_template();

Displays anything related to comments and can be deleted in the block.

Navigation buttons

wp_link_pages('before=<p>&after=</p>');

Next and previous articles.
One argument that is a string of parameters separated by &.
Values:
- before: HTML code to be inserted before.
- after: HTML code must be inserted after.

Edit button

 edit_post_link('Edit this entry.', '<p>', '</p>');

It fits in a loop. The three optional arguments are:
- wording. For example, Edit.
- HTML code inserted before.
- HTML code inserted after.

The button is displayed if you have edit rights.

Page format

The full article page format may look like this:

<?php
get_header();  

if(have_posts()): while (have_posts(): the post();

the title('<h1>', '<h1>');
the_content();
edit_post_link();
wp_link_pages();
endwhile;

endif;

get_sidebar();
get_footer();
?>

See also