• Resolved Evakos

    (@chrissyb)


    I have no idea whether I’ve implemented WP strangely into my site or not, and I have to keep it brief…

    I’ve used this code:

    <?php
    $how_many=5; //How many posts do you want to show
    require_once(“blog/wp-config.php”); // Change this for your path to wp-config.php file ?>
    <ol id=”new_post”>
    <?
    $news=$wpdb->get_results(“SELECT ID,post_title FROM $wpdb->posts
    WHERE post_status= \”publish\” ORDER BY ‘ID’ DESC LIMIT “.$how_many);
    foreach($news as $np){
    print (”

    • <a href=\””);
      echo get_permalink($np->ID);
      print (“\”>$np->post_title
    • “);
      } ?>

      This summarises the posts, but is it possible to add a line or two to display the date, without turning the way I’ve implemented it into my site on it’s head.

      I’d be grateful for any feedback! ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • EDITED* Handy told me basically what was going on with it.. ?? =)

    WHERE are you adding this code? WHY are you adding this code? I’ve NEVER seen this done before… =/ What’s the URL to your blog?

    Calling the wp-config.php file in ANY theme file is BAD, well.. to me is.. =P

    require_once("blog/wp-config.php"); // Change this for your path to wp-config.php file ?>

    The date call tag I use is this:
    <?php the_time('F jS, Y') ?>

    Like you see on my blog, from name link. I have mine in the index.php file. Maybe I’m not quite sure what your intentions are.. perhaps? Anyone else have a clue maybe?

    spencerp

    @chrissyb – check out the Posts table using something like phpMyAdmin. Grab the name of the column with the post date in it and add it to the SELECT in
    $news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts [...]

    Thread Starter Evakos

    (@chrissyb)

    Hey thanks guys!

    Let me try out your ideas. Spencerp I thought I had done mine strangely, my site is only local at the mo because I wouldn’t mind you having a look – but no I didn’t build it round the index page – I’ve done it a weird way because I did’t want to build the whole site around the theme – if you follow?

    This just seemed really odd to me.

    I’ll come back to you both – thanks! ??

    Thread Starter Evakos

    (@chrissyb)

    Oh dear…

    I was forgetting to declare this:

    print (“$np->post_date”);

    BUT I was making the ‘select’ call

    It works now….But…

    Can somebody talk to me about why it is a bad idea to call the wp config file outside of the theme templates?

    Is this a security hole ??

    Can somebody tell me the way I’ve put my blog together is not stupid LOL

    Thank you you are great…

    Thread Starter Evakos

    (@chrissyb)

    Sorry me again:

    Of course that code gives the mysql datetime format – what PHP would I use to alter the format of that date. I have no idea how the WP templates parse the date – it isn’t obvious to me:

    <?php
    $how_many=5; //How many posts do you want to show
    require_once(“blog/wp-config.php”); // Change this for your path to wp-config.php file ?>
    <ol id=”new_post”>
    <?
    $news=$wpdb->get_results(“SELECT ID,post_title, post_date FROM $wpdb->posts
    WHERE post_status= \”publish\” ORDER BY ‘ID’ DESC LIMIT “.$how_many);
    foreach($news as $np){
    print (”

    • <a href=\””);
      echo get_permalink($np->ID);
      print (“\”>$np->post_title
    • “);
      print (“<b>$np->post_date</b>”);
      }
      ?>

      This prints: 2006-09-08 18:24:54

      Is there any easy way to convert it?

    Can somebody talk to me about why it is a bad idea to call the wp config file outside of the theme templates?

    Well, there are other “cleaner” ways. Have a look at this article (2nd page) https://www.transycan.net/blogtest/2005/07/05/integrate/

    Thread Starter Evakos

    (@chrissyb)

    Handy Solo,

    I don’t know what nationality you are but in the UK they have a phrase – ‘arse about face’.

    That’s how I had the blog intergrated…

    Thanks – It is now working how I’d like ??

    Ah, where I grew up we’d call that “bass-ackwards” ??

    Glad you got it all sorted out, mark this one as “Resolved” (up at the top)?

    Happy Blogging!

    Handy, I owe you big time! ?? Thanks man, was out helping the grandparents with stuff.. Atleast ya got her working/going on the right track. ?? =)

    @crissyb, Glad to hear you got it working for you, and such. =)

    spencerp

    Thread Starter Evakos

    (@chrissyb)

    Thanks guys,

    I can’t make the post as resolved it is saying ‘something odd happened’.

    Perhaps it is the pesky zone alarm again…

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘The date in the post summary.’ is closed to new replies.