WordPress.org

Ready to get started?Download WordPress

Forums

query_posts issue (1 post)

  1. mrFlamer
    Member
    Posted 3 years ago #

    Hey.
    I'm having a little issue with the WP script.

    Brief description
    I want to serve dynamic some pages and I made a preg_match over the query_string. So far, so good. But when I include my custom page from the templates directory, query_posts function ignores all my arguments that I pass to it and returns all posts with that custom_type. I'm using a plugin to pass multiple custom fields to query_posts function.

    Details are poetry... :)
    Ok, so I have some products and a custom post type for them. My URL should be something like /products/{gender}/{size}. I wrote a little function that I "auto-appeal" in my template's function.php file called specialPage(). It checks the $_SERVER["REQUEST_URI"] and if this string applies for some conditions, it includes a different page called 'list-products.php' located in my template directory. So far, so good. The bad thing is that to avoid the 404 message, I added a 'die' after requiring the needed page. And, inside the page, query_posts function behaves like I give no arguments to it and returns all unnecessary posts. I know it may have been a rude solution to include that page and I'm sure there are better ways to do what I want to; that's why I'm opened to opinions regarding my error.
    PHP-FPM throws the following error: [28-Jul-2011 23:09:14] PHP Catchable fatal error: Object of class WP_Error could not be converted to string in[...]. This happens when I loop the posts and want to print any $post's data ($post is, of course, a stdclass object).

    My first guess is that there are some globals that aren't loaded/processes that aren't executed since I kill the script. :)

    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic