質問

I am trying to display posts from a specific cateogry in WordPress in a footer column on a site. It works fine unless the footer is displaying on a page that is integrated in either WHMCS or Magento. For some reason, on those pages within those apps, it still displays the blog post column, but instead of returning the last X # of posts in the specified category, it seems to return the last post X # of times.

For example, here is the stand alone Wordpress blog column pulling from a specific category:

http://www.thinkshovels.com/includes/latest_work.php

This is exactly what we want shown throughout the site, however if you visit http://www.thinkshovels.com/service/ you can see that the middle column is not displaying that info.

Here is the code querying wordpress:

define('WP_USE_THEMES', false); require('/home/shovels/public_html/blog/wp-load.php');

$qarray = array('cat' => '5', 'posts_per_page' => 4);
query_posts($qarray);

while (have_posts()): the_post();

$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );

I'm not sure if I have done something wrong here, or if there is a better way to approach this, but it seems that WHMCS and Magento break something with these queries.

Any tips/advice appreciated! Thanks.

役に立ちましたか?

解決

Instead of query_posts try to use get_posts instead.

According to the article from Developer.WordPress.com you should avoid using query_posts.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top