Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:45:20+00:00 2026-06-11T06:45:20+00:00

Everything works in my code beside posts_per_page (the number of posts it will display).

  • 0

Everything works in my code beside posts_per_page (the number of posts it will display). Here is part of my WordPress code:

<?php 
$category = get_the_category();
$current_category = $category[0]->term_id;
$qarr = array(
    'posts_per_page' => $posts_number,
    'cat' => $current_category,
    'tag' => 'pinned', // tag filtered
    'post__not_in' => array(get_the_ID())
);
$q = new WP_Query($qarr);
if($q->have_posts()) : while ($q->have_posts()) : $q->the_post();
?>

Why does it not work? I have read the documentation and do not understand what the issue is.

Here is the full code if you want to view and test it, just set a number for $posts_number: http://pastebin.com/uNsynNiM

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:45:22+00:00Added an answer on June 11, 2026 at 6:45 am

    From your previous questions, your theme is primarily using query_posts to run any and all Post Queries against your database. Since this alters the main loop, WP_Query and get_posts are also affected by any and all existing calls to query_posts. I’m fairly certain that the WP_Query call in your Widget is being affected by a rogue query_posts call somewhere.

    My suggestion, since it would probably take quite a bit of effort to convert your theme from all instances of query_posts to WP_Query, would be to temporarily use ‘showposts’ since that’s what essentially fixes the problem. I would still advise switching all calls to the query_posts function to WP_Query, only because there is a significant increase in performance by doing so, but ultimately, that would require a significant effort on your part to fix a rather small problem.

    Personally, would I do it? As an exercise in good practice, I probably would, yes. Would I say it’s worth it? It depends on the project. If this is just a personal project, I wouldn’t say it’s necessary.

    Good luck with this, and I hope it all works out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented this Jquery show/hide code and everything works fine except that the box
Following code is a pretty simple and complete JQuery Dialog. Everything works. Problem is
The following bit of code works great in everything but IE. In IE, the
Hi there I have edited some code I have found on-line and everything works
Following this code my button works perfectly: http://twitter.github.com/bootstrap/javascript.html#modals Fades and everything. I want to
Everything works as supposed to on the Django development server. In Apache, the django
Everything works fine locally when I do as follows: cat input | python mapper.py
Everything works with no errors, but in the xml, tvfinalgrade stays 0.0... Why isn't
Everything works fine, the only problem is that it loads very slow. It takes
I created a new product type and everything works except the indexing of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.