WordPress.org

Ready to get started?Download WordPress

Forums

Help: list all posts in same category as current p (5 posts)

  1. Kerim
    Member
    Posted 10 years ago #

    I've been struggling over this for a week, but I'm just not good enough at coding PHP to do it myself. Can anyone help me? I'd like to produce a list of all the posts in the same category as the currently displayed post. For example, if the post X is in category #1, I'd like a list of all the posts in category #1 (including post X) listed in alphabetical order by name. Just the title wrapped in a permalink.
    I'd be happy to buy someone something from their Amazon wishlist in exchange for writing the code for me!
    Apologies for cross-posting, but I am really desperate to get my site up and running, and this is the last hurdle, and I thought that maybe the Hacks forum would be a better place to try than the "tips" forum. Here is the other post if you want to see my laughable efforts at coding from scratch in PHP:
    http://wordpress.org/support/3/3495
    Thanks!

  2. Kerim
    Member
    Posted 10 years ago #

    Two problems. #1 is this:
    SQL/DB Error:
    [You have an error in your SQL syntax near 'ORDER BY post_status DESC, post_date DESC LIMIT 30' at line 1]
    SELECT DISTINCT * FROM wp_posts WHERE (post_status = 'publish' || post_status = 'sticky') AND post_category= ORDER BY post_status DESC, post_date DESC LIMIT 30
    The number 2 problem is I'm not sure how to write the loop. I know it should look something like this, but I'm not sure how to modify it:
    $cat=posts_of_cat();
    $blog=1;
    require_once("wp-blog-header.php");
    foreach ($post as $posts) { start_wp(); //start of loop
    ?>

  3. " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?>
    <?
    } //end of loop

  • Kerim
    Member
    Posted 10 years ago #

    Oops. That was meant for the other thread. (I really wish they would use PHPBB for these forums instead of miniBB - miniBB is very difficult to use - and it difficult to read as well.)

  • OperaManiac
    Member
    Posted 10 years ago #

    nice...

  • davidchait
    Member
    Posted 10 years ago #

    see other post...

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.