WordPress custom template page invalidation solution summary

Source: Internet
Author: User

Solution to WP paging failure:

1. Log onto the background of the blog and click "edit" under the "Appearance" tab to go to the topic editing page.

2. Find

The code is as follows: Copy code

<? Php query_posts ('showposts = 9 & cat = 25 ');? Then change:

<? Php $ limit = get_option ('posts _ per_page ');
$ Paged = (get_query_var ('paged '))? Get_query_var ('paged'): 1;
Query_posts ('& showposts ='. $ limit = 5. '& paged ='. $ paged. '& cat = 25 ');
$ Wp_query-> is_archive = true; $ wp_query-> is_home = false;
?>

5 After limit is the number of files displayed on each page, and 25 is the ID number of the category.

4. Save the update file.


Query_posts paging failure solution

Query_post is indeed powerful. You can use it to customize the articles you want to call. Now, we want to use it to implement the pagination of articles, in my topic, I set 10 articles on each page in the background, but in my image category, I want to display 9 images. The following code is required:

The code is as follows: Copy code

<? Php

Query_posts ('showposts = 9 & cat = 64 & prime ;);

If (have_posts (): while (have_posts (): the_post ();?>

<Div class = "pic" id = "post-<? Php the_ID ();?>" <? Php post_class () ;?>>

.....

</Div>

<? Php endwhile; endif;?>

In this way, nine images are displayed on each page, but the content on the second page is the same as that on the first page...

Modify the code here.

The code is as follows: Copy code

<? Php

$ Limit = get_option ('posts _ per_page ');

$ Paged = (get_query_var ('paged '))? Get_query_var ('paged'): 1;

Query_posts ('& showposts ='. $ limit = 9. '& paged ='. $ paged. '& cat = 9 & prime ;);

$ Wp_query-> is_archive = true;

$ Wp_query-> is_home = false;

If (have_posts (): while (have_posts (): the_post ();?>

<Div class = "pic" id = "post-<? Php the_ID ();?>" <? Php post_class () ;?>>

.....

</Div>

<? Php endwhile; endif;?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.