WordPress使用query_posts分页时,分页不成功的方法

下列函数,是使用Query_post函数进行输入出。下方的例子中,每页分为4个。

但是按照这个例子,下一页是不成功的。直接报404错误。

因为在后台-外观-设置-阅读里,设置的是每页展示10篇文章。这导致了某种冲突。

<?php  // 下面这一行代码是必须的,不然你的首页不能分页global $wp_query;$cat_ID = get_query_var('cat');// 说明:获取完整URL$WholePageURL = get_category_link($cat_ID);$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;$args = array(    // 这里以下面的方式添加query_posts参数,具体参数可以参加官方文档    'cat'=> $cat_ID,    'posts_per_page'=>4,    'paged' => $paged);

需要你在设置-阅读里面,把默认的10篇每页改成4篇每页。

或者,在functions.php函数里添加如下内容:

这里需要注意的是,Post_Per_page后面的参数,要和你页面里query_post的值相同才行。

function custom_posts_per_page($query){if( is_category('wordpress-themes')  && $query->is_main_query() ) {$query->set('posts_per_page', 4);}} www.111cn.netadd_action('pre_get_posts', 'custom_posts_per_page');

谷歌公布 2019 年度搜索热词榜单

最热门搜索词

  1.Disney Plus

  2.Cameron Boyce

  3.Nipsey Hussle

  4.Hurricane Dorian

  5.Antonio Brown

  6.Luke Perry

  7.Avengers Endgame

  8.Game of Thrones

  9.iPhone 11

  10.Jussie Smollett

  新闻搜索

  1.Hurricane Dorian

  2.Notre Dame Cathedral

  3.Womens World Cup

  4.Area 51 raid

  5.Copa America

  6.El Paso shooting

  7.Sri Lanka

  8.Government shutdown

  9.Equifax data breach settlement

  10.California earthquake

  人物搜索

  1.Antonio Brown

  2.Jussie Smollett

  3.James Charles

  4.Kevin Hart

  5.R。 Kelly

  6.21 Savage

  7.Lori Loughlin

  8.Jordyn Woods

  9.Bryce Harper

  10.Robert Kraft

  逝者搜索

  1.Cameron Boyce

  2.Nipsey Hussle

  3.Luke Perry

  4.Jeffrey Epstein

  5.Tyler Skaggs

  6.Beth Chapman

  7.John Witherspoon

  8.John Singleton

  9.Eddie Money

  10.Elijah Cummings

  演员搜索

  1.Jussie Smollett

  2.Kevin Hart

  3.Lori Loughlin

  4.Felicity Huffman

  5.Keanu Reeves

  6.Rami Malek

  7.Joaquin Phoenix

  8.Kate Beckinsale

  9.Halle Bailey

  10.Maisie Williams

  电影搜索

  1.Avengers Endgame

  2.Captain Marvel

  3.Joker

  4.Toy Story 4

  5.Lion King

  6.It Chapter Two

  7.Frozen 2

  8.Once Upon a Time In Hollywood

  9.Midsommar

  10.Scary Stories to Tell in the Dark

  电视剧搜索

  1.Game of Thrones

  2.Stranger Things

  3.When They See Us

  4.Chernobyl

  5.The Mandalorian

  6.The Umbrella Academy

  7.Euphoria

  8.Dead to Me

  9.Surviving R。 Kelly

  10.The Boys

  歌曲搜索

  1.Old Town Road

  2.7 Rings

  3.Shallow

  4.Sunflower

  5.Truth Hurts

  6.Lose You To Love Me

  7.Sicko Mode

  8.thank u, next

  9.Act Up

  10.Bury a Friend

  更详细的排行榜,可以访问 google.com/2019 来了解更多。

Changzhou Sandx Plastics Co., Ltd.

Business TypeManufacturer
Main MarketsNorth America South America Southeast Asia Africa Western Eu
Main ProductsPlastic pail,plastic bucket,straight side pail,golf ball pail,square pail
EntrepreneurMr. Xiang
Employees11 – 50 People
RegionChina
CategoryAgriculture – Agricultural & Gardening Tools
Link ToolChina Agriculture – China Agricultural & Gardening Tools
TagsPail Plastic – Plastic Pail – Plastic Pails

Company Introduction

Changzhou Sandx Plastics Co., Ltd. specializes in the manufacture and marketing of rigid plastic pails in China, and serves a variety of markets from consumer food to construction and auto sales promotion products to golf ball package. We brought high-quality plastic pails to market in 2005. Since then, we have applied our expertise to improving the design and manufacture of rigid plastic pails for a variety of industrial and consumer applications, by adding user-friendly features and incorporating lean manufacturing practices. Today we are the well-known manufacturer in the field in China, and our high quality pails are now also available in the USA, Canada, Japan, Australia, and India.SANDX's key strengths are innovation in packaging design and rapid new product development for consumers (using sophisticated prototyping systems). With high quality products, better price, world-class graphics and excellent customer service, we are also committed to the concept of "lean production", focusing on eliminating waste, reducing variability in manufacturing, and continuously improving our production efficiency. Our commitment is to challenge the current status, develop innovative new products and optimize manufacturing efficiency. Therefore, we can serve our customers better in a highly competitive marketplace.Our state-of-the-art graphics ensure customers get great brand presence on the store shelf. We used thermal printing, and this can help customers print complicated logos and pictures on the pail.We are also in the vanguard of reducing the environmental impact of plastic pails, through developing innovative designs that reducing weight without compromising quality or strength. Our pails are designed to be recyclable and reusable when empty (we designed a special lid-opener for it).Products/services: Round, square and straight side pail, plastic mould, and customized pailAvailability:Food service, construction, dairy, fishing, medical waste, petroleum, and sales promotionMarkets:China, Japan, India, the USA, Canada, Mexico, Australia, and Europe

Contact Information

Contact PersonMr. John X
Telephone86-519-85138026
Fax Number86-519-85158887
Websitehttp://www.sandxplastics.com.cn
Post Code213022
Address217-4153#, North Jinling Road, Xinbei District, Changzhou, Jiang
Online MapChangzhou Sandx Plastics Co., Ltd. Map & Directions

Company ReviewsChangzhou Sandx Plastics Co., Ltd.

JM Plastics.Co.,Ltd.

Business TypeManufacturer, Trading Company
Main MarketsSouth America Eastern Europe Western Europe
Main ProductsPE Tarpaulins,PVC Tarpaulins
Entrepreneur
Employees101 – 500 People
RegionSouth Korea
CategoryAgriculture – Agricultural & Gardening Tools
Link ToolSouth Korea Agriculture – South Korea Agricultural & Gardening Tools
TagsOverseas Marketing – Pe Tarpaulins – Worldwide Market

Company Introduction

We have been manufacturing a P.E tarps over 12 years throughout the worldwide market.Through the time, we are able to accumulate a lot of overseas marketing experiences & mamufacturing know-how and they taught us how to meet customers' requirements and get close, therefore if we have any opportunity from you, we will do our utmost to make our mutual and fruitful business relationship.For further info. please kindly pop into our web. www.jmplastics.co.kr

Contact Information

Contact PersonMr. Zoe Moon
Telephone82-53-3417774
Fax Number
Websitehttp://www.jmplastics.co.kr
Post Code39-1
Address1Ga, Sam-deok dong, Jung-gu, Daegu, South Korea
Online MapJM Plastics.Co.,Ltd. Map & Directions

Company ReviewsJM Plastics.Co.,Ltd.

MUNRO INTERNATIONAL

Business TypeManufacturer, Trading Company
Main MarketsEastern Europe Western Europe
Main ProductsBeauty Kits, Barber Scissors, Gardening Tools, Surgical Instruments
EntrepreneurSami Ullah
Employees51 – 100 People
RegionPakistan
CategoryAgriculture – Agricultural & Gardening Tools
Link ToolPakistan Agriculture – Pakistan Agricultural & Gardening Tools
TagsBarber Scissors – Boxing Products – Gardening Tools

Company Introduction

We are manufacturer and exporters for all high quality manicures-Barber scisors, gardening tools and Surgical Instrument-offer very reasonable prices. we also expertise in martial arts and boxing products.

Contact Information

Contact PersonMr. Yousaf Butt
Telephone92-52-3008616449
Fax Number92-52-3511181
Websitehttps://www. .net/corp-639956.html
Post Code51310
AddressArazi Yaqoob, Sialkot, Punjab, Pakistan
Online MapMUNRO INTERNATIONAL Map & Directions

Company ReviewsMUNRO INTERNATIONAL