[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"\u002Fblog\u002Fwpgraphql-increase-post-query-limit":3,"$fyilMrmmQV6Ow2iRDmngteKGZGuQb8dnzWF0nuayIGjE":185,"i-local-icon:calendar-days":189,"i-local-icon:tag":194,"i-local-icon:eye":196},{"id":4,"title":5,"body":6,"categories_slug":172,"comment_count":175,"date_published":176,"description":177,"extension":178,"meta":179,"navigation":180,"path":181,"seo":182,"stem":183,"__hash__":184},"content\u002Fblog\u002F14.wpgraphql-increase-post-query-limit.md","How to increase the WPGraphQL query limit using graphql_connection_max_query_amount",{"type":7,"value":8,"toc":168},"minimark",[9,13,18,23,36,45,51,54,62,66,74,164],[10,11,5],"h1",{"id":12},"how-to-increase-the-wpgraphql-query-limit-using-graphql_connection_max_query_amount",[14,15],"meta-card",{":categories":16,":date":17},"categories_slug","date_published",[19,20,22],"h2",{"id":21},"overview","Overview",[24,25,26,27,35],"p",{},"By default, ",[28,29,34],"a",{":target":30,"href":31,"rel":32},"\\_blank","https:\u002F\u002Fwww.wpgraphql.com\u002F",[33],"nofollow","WPGraphQL"," limits the amount of posts per page that you can query at any one time to 100.",[24,37,38,39,44],{},"As per the ",[28,40,43],{":target":30,"href":41,"rel":42},"https:\u002F\u002Fwww.wpgraphql.com\u002Ffilters\u002Fgraphql_connection_max_query_amount",[33],"WPGraphQL documentation"," the reasoning for this is:",[46,47,48],"blockquote",{},[24,49,50],{},"The default is 100 to prevent queries from being exceedingly resource intensive, however individual systems can override this for their specific needs.",[24,52,53],{},"While the warning about the default value being set low is sensible, there are many valid reasons as to why you would want to increase this value.",[24,55,56,57,61],{},"For example, maybe you want to get a full list of all post titles and you have more than 100 posts on your site. Or maybe you need to add all your posts and their corresponding publication date and URL to a ",[58,59,60],"em",{},"sitemap.xml"," file.",[19,63,65],{"id":64},"solution-add-new-function-and-filter","Solution: Add new function and filter",[24,67,68,69,73],{},"In your ",[70,71,72],"strong",{},"functions.php"," file within your Wordpress theme, add the following code snippet:",[75,76,81],"pre",{"className":77,"code":78,"language":79,"meta":80,"style":80},"language-php shiki shiki-themes github-dark","\u002F\u002F This will return a maximum of 200 queries - adjust to suit.\nadd_filter('graphql_connection_max_query_amount',\nfunction (int $max_amount, $source, array $args, $context, $info) {\n  return 200;\n}, 10, 5);\n","php","",[82,83,84,93,111,133,146],"code",{"__ignoreMap":80},[85,86,89],"span",{"class":87,"line":88},"line",1,[85,90,92],{"class":91},"sAwPA","\u002F\u002F This will return a maximum of 200 queries - adjust to suit.\n",[85,94,96,100,104,108],{"class":87,"line":95},2,[85,97,99],{"class":98},"svObZ","add_filter",[85,101,103],{"class":102},"s95oV","(",[85,105,107],{"class":106},"sU2Wk","'graphql_connection_max_query_amount'",[85,109,110],{"class":102},",\n",[85,112,114,118,121,124,127,130],{"class":87,"line":113},3,[85,115,117],{"class":116},"snl16","function",[85,119,120],{"class":102}," (",[85,122,123],{"class":116},"int",[85,125,126],{"class":102}," $max_amount, $source, ",[85,128,129],{"class":116},"array",[85,131,132],{"class":102}," $args, $context, $info) {\n",[85,134,136,139,143],{"class":87,"line":135},4,[85,137,138],{"class":116},"  return",[85,140,142],{"class":141},"sDLfK"," 200",[85,144,145],{"class":102},";\n",[85,147,149,152,155,158,161],{"class":87,"line":148},5,[85,150,151],{"class":102},"}, ",[85,153,154],{"class":141},"10",[85,156,157],{"class":102},", ",[85,159,160],{"class":141},"5",[85,162,163],{"class":102},");\n",[165,166,167],"style",{},"html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":80,"searchDepth":95,"depth":95,"links":169},[170,171],{"id":21,"depth":95,"text":22},{"id":64,"depth":95,"text":65},[173,174],"development","wordpress",null,"2024-07-16","By default, WPGraphQL limits the amount of posts per page that you can query at any one time to 100.  But by adding a simple filter & function you can change this limit to any value.","md",{},true,"\u002Fblog\u002Fwpgraphql-increase-post-query-limit",{"title":5,"description":177},"blog\u002F14.wpgraphql-increase-post-query-limit","POc1Ry6K1flXgWsLJ3VHy1vOhjhQuc1MSEdOnlFxZ2g",[186],{"id":187,"name":181,"count":188},27,2085,{"left":190,"top":190,"width":191,"height":191,"rotate":190,"vFlip":192,"hFlip":192,"body":193},0,24,false,"\u003Cpath\n    fill=\"none\"\n    stroke=\"currentColor\"\n    stroke-linecap=\"round\"\n    stroke-linejoin=\"round\"\n    stroke-width=\"1.5\"\n    d=\"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5m-9-6h.008v.008H12zM12 15h.008v.008H12zm0 2.25h.008v.008H12zM9.75 15h.008v.008H9.75zm0 2.25h.008v.008H9.75zM7.5 15h.008v.008H7.5zm0 2.25h.008v.008H7.5zm6.75-4.5h.008v.008h-.008zm0 2.25h.008v.008h-.008zm0 2.25h.008v.008h-.008zm2.25-4.5h.008v.008H16.5zm0 2.25h.008v.008H16.5z\" \u002F>",{"left":190,"top":190,"width":191,"height":191,"rotate":190,"vFlip":192,"hFlip":192,"body":195},"\u003Cg\n    fill=\"none\"\n    stroke=\"currentColor\"\n    stroke-linecap=\"round\"\n    stroke-linejoin=\"round\"\n    stroke-width=\"1.5\">\n    \u003Cpath\n      d=\"M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.1 18.1 0 0 0 5.224-5.223c.54-.827.368-1.908-.33-2.607l-9.583-9.58A2.25 2.25 0 0 0 9.568 3\" \u002F>\n    \u003Cpath d=\"M6 6h.008v.008H6z\" \u002F>\n  \u003C\u002Fg>",{"left":190,"top":190,"width":191,"height":191,"rotate":190,"vFlip":192,"hFlip":192,"body":197},"\u003Cg\n    fill=\"none\"\n    stroke=\"currentColor\"\n    stroke-linecap=\"round\"\n    stroke-linejoin=\"round\"\n    stroke-width=\"1.5\">\n    \u003Cpath\n      d=\"M2.036 12.322a1 1 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178c.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178\" \u002F>\n    \u003Cpath d=\"M15 12a3 3 0 1 1-6 0a3 3 0 0 1 6 0\" \u002F>\n  \u003C\u002Fg>"]