• Hi guys,

    sorry for the multiple questions ??

    I would like to showcase TWO different posts on my welcome page

    in my home.php I placed the query_posts tag
    but i get only ONE post
    here is the tag i am using:

    <?php
    query_posts(‘p=21,43’);
    ?>

    any suggestions how i get both post id=21, and below it post id=43 ?

    Thank you !

Viewing 13 replies - 1 through 13 (of 13 total)
  • I don’t believe you can use query_posts() for that (mutliple posts), but I’m not sure.

    Just use this instead:

    $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID='21' OR ID='43'");

    Thread Starter gs06

    (@gs06)

    Thanks

    tried, but got jibrish

    i used the code as follows:

    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    <?php
    $posts = $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE ID=’21’ OR ID=’43′”);
    ?>

    this is not on my index page but home.php
    what am i doing wrong ?

    tried, but got jibrish

    Okay, what was it?

    Thread Starter gs06

    (@gs06)

    yea exactlly
    got jibrish as well
    how do i incoperate your code
    to my home.php page ?

    He means what was the jibrish exactly?

    Thread Starter gs06

    (@gs06)

    the 2 posts are there but then
    i get a bunch of strange error-posts :

    Category: Uncategorized

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AND comment_approved = ‘1” at line 1]
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’;
    0 Comments

    , Edit This

    Category: Uncategorized

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AND comment_approved = ‘1” at line 1]
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’;
    0 Comments

    , Edit This

    Category: Uncategorized

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AND comment_approved = ‘1” at line 1]
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’;
    0 Comments

    , Edit This

    Category: Uncategorized

    WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘AND comment_approved = ‘1” at line 1]
    SELECT COUNT(comment_ID) FROM wp_comments WHERE comment_post_ID = AND comment_approved = ‘1’;

    Please post the contents of your entire home.php or whatever: https://pastecode.com

    Thread Starter gs06

    (@gs06)

    sure

    here you go :

    https://pastecode.com/3993

    You need to add the code as I mentioned above. ??

    https://pastecode.com/4030

    Thread Starter gs06

    (@gs06)

    Thanks Viper007Bond.
    i tried it
    but this line >>
    <?php else : ?>
    keeps coming as error > > parse error, unexpected $
    i tried to delete the line
    no good

    tried to delete

    <?php else : ?>

    <?php _e(‘Sorry, no posts matched your criteria.’); ?>

    <?php endif ?>

    no good

    suggestions ?

    Thread Starter gs06

    (@gs06)

    anyone ?

    I had this very same problem … it was fixed very easily … i went through disabling all my plugins one by one .. the 3rd plugin i disabled fixed it .. it was my Adhesive plugin that was messing it up.
    https://www.redalt.com/downloads/ was where it was from .. and now doesn’t seem to be kept up to date .. so if i need sticky posts i won’t be using it any more !

    I have the same error on the index page at https://www.amyloo.com/clipoftheweek

    Like one of the first posters in this thread, it happened after I added a query_post — in my case to exclude a particular category of posts from the index.

    Like the just-previous poster, I isolated the troublemaker. It’s the theme; when I revert to the basic theme, the error goes away. Problem is the thememaker says my question is beyond his scope of support https://forums.wpthemes.info/comments.php?DiscussionID=126/

    So now what? I’ll likely end up starting over with a new theme based on the default rather than modifying a theme that doesn’t look anything like what I ended up with anyway! But for a quick fix, I thought it might be worth asking if anybody has any ideas. Thanks.

    /amyloo

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to showcase TWO different posts using > query_posts’ is closed to new replies.