Wordpress Category Template

Worpress Category Template

The template for displaying category pages. There is no need to limit yourself to creating a static page template for your WordPress page. You can edit the custom menu to add a "tab" to your site that displays only those posts that share the same blog category, tag, post format, and so on.

Which template file is used?

Clicking a hyperlink to one of the categories on your site takes a user to a page that lists the contributions in that particular category in order, from the most recent at the top to the oldest at the bottom. Plenty of viewing options are available, as well as the question of whether to show the full article or extracts from the article, and what extra information to show (title, artist, publication date, last changed clock, etc.).

Describes how to modify what happens when the Blogsiewer visits one of the category pages of your website. So if you're new to template file, you might want to start by reading the sections Using Themes and Stepping Into Templates. Permal links to category repositories are managed by the permal link setting.

Which template file is used? So the first thing to do when changing what happens when someone goes to a category page is to find out which of your topic's file types should be used to view the post. It is called the template tree. When it comes to category, the hierarchies are quite straightforward.

So if you want the category whose ID number is 6 to look different from the one it currently is (and be different from other category pages), you would want to make a category 6 category phone booklet. When you want all category pages to look different than other category pages (e.g. date and authors' archives), you want to change or add the category. pdf-files.

To change the appearance of all pages in the archives, you can either edit or edit the archive.php files. If you change the index. directory name, you will impact your whole blogs. When you need to recreate a new filename, it is advisable to copy it from the next filename in the existing tree.

If you want a specific ad for category 6, for example, copy the category first. pdf or if you don't have one, use archives. pdf, and so on. Once you've found out which template files in your topic folder you need to change to change the appearance of category pages, let's look at some samples.

Editing your template file" in these samples means that you must modify the template selected in the above section. Say you want a statical text to appear before the posting queue on your category page(s). With " statically " we mean text, which stays the same, no questions asked, no questions asked and no questions asked.

This is how it works: Add the following to the loop section of your template file: It is a text that is displayed at the top of the Category page. One of the more sophisticated options is that you want different texts to be displayed according to which category page the user visits.

Then, append the "default" text to the master category. pdf-document, and generate specific category #. pdf-files (with a separate text revision as described in the introduction) for each category that needs a specific text above. However, this creates a large number of directories in your topic folder and can be prevented with the following outside source code:

This is a general text describing all other category pages. This is done as follows. Tests if we are in category A, if we then display the first piece of text, but if we are not, then we test if we are in category A. If we then display this piece of text, and if it is neither category A nor category A, then you display this standard text.

One more thing that can occur is that if your category contains more articles than it fits on one page (according to the options for reading blogs you specified in the administration panel of your blog), the category library will be divided into several pages. You might want to show your text only when the observer is on the first page of the results, or you might want to show other text for the other pages.

p>Text for following pages of the category. You can also enter the category name at the top of the page. So if this is not already part of your template, you can make it by doing something like this over the loop: You may want to reduce the sizes of your category pages.

This can be done by viewing extracts rather than the full contents of each post. In order to do this, just find out where the_content() is inside the loop in your template and substitute the_excerpt() for it. On the other hand, if your thread is showing extracts and you want full postings, substitute those_excerpt for them.

A further thing that is interesting in a category archives page is to substitute the contents of the posting with an icon that points to your posting. In order to do this, you must first insert pictures into the clipping portions of your contributions. Here is how to do that, for a contribution:

Load an uploaded picture onto the post-processing monitor. You can use the Uploads / Browse page to add the picture to your posts. Duplicate the pasted HTML-IMG tag and pasted it into the "Optional Extract" section of the post-processing page. Stop posting the article contents (you can delete the image) and make the article public.

You must now change your template. We use a trick: The_excerpt_rss() template tags does not put a section tags around the section. Here is what you need to insert into your template instead of using the_content: So, if you are going to do this, you should probably adjust your settings so that the full articles are displayed in RSS streams and not in extracts.

Show what category to your visitor? In order to choose which category you want to see on any page, e.g. an archives page, use this one. bargs = arrays ('category' => ID,'posts_per_page' => 5); $myposts = get_posts( $args); foreach( $myposts as $post ):setup_postdata($post); This uses the getposts template tags to call an arrays of contributions that match the specified criterias.

Make sure you modify "ID" to the category ID number you want to view. Parameters post_per_page specifies how many articles you want to show in this category. You can also use conditional tags to build archive that react to requirements specified by the URI or contexts.

If, for example, you want to make sure that a visitor to http://yourblog. com/2008/02/ displays February 2008 contributions first, just append this source to your archives. pdf-document.

Auch interessant

Mehr zum Thema