Jump to content

[Wordpress] PHP Query Issue


lethyl

Recommended Posts

Hello everyone, thanks for taking the time to read this issue.

 

`<?php $query = "SELECT post_title, MONTH( post_date ) AS month ,  YEAR( post_date ) AS year, DAY( post_date ) AS day , id FROM $wpdb->posts WHERE post_status = 'publish' AND post_date <= now( ) and post_type = 'post' ORDER BY post_date DESC";  if ( $posts = $wpdb->get_results($query) ) {foreach ($posts as $post) { ?>

<li><span class="archive-date"><?php echo date("F jS, Y",mktime(0, 0, 0, $post->month, $post->day, $post->year)) ?></span> <a href="<?php echo get_permalink($post->id)?>"><?php echo $post->post_title ?></a></li>

 

<?php } } ?> `

 

Here's the run down of everything:

 

- My website is http://kristopherlouie.com

 

- I'm using <a href="http://wordpress.org/extend/plugins/privatepost/">PrivatePost</a> to allow only registered users to view private entries

 

- I'm using the above code as my archive list.

 

- When you are not logged in, you cannot see any of the private entries on the main page or on the archive list.

 

PROBLEM: However, when you are logged in you can see the private entries (intentional) but you will also see doubles of each private entry when you view the archives.

 

I've tried a lot of loop hacks and editing the query = "" clause, but I can't seem to get it to work.

 

Any feedback would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/122237-wordpress-php-query-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.