Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages » Excerpts, Read more, Pagination »

[SOLVED] Showing Posts With 'Draft' Status


  #1  
Old Nov 29, 2009, 04:40 PM
gcarson
 
26 posts · Oct 2009
Hi,

Trying to figure this out and wondering if anyone here could help. I'm looking to show my posts with draft status. I've seen some codes that work but not for exactly what I'm looking to do. Most of them will list all drafts which is great but not exactly what I want to do. I only want to show draft posts on tag pages and I only want to show drafts with that tag. So I have entered the following code after my loop in the content below the loop section. Here is one of my attempts.

Code:
<?php if ( is_tag() ) { ?>

<?php /* If there are any posts: */
if (post_status == "draft" ): ?>

<div class="sidebar-box">

    <?php
    while (have_posts()) : the_post(); ?>
        <ul>
          <li>
           <?php the_title(); ?>
          </li>
        </ul>
    <?php /* END of the LOOP */
	endwhile; ?>
<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>
        <div>
        <ul>
          <li><?php _e('Nothing scheduled'); ?></li>
        </ul>
        </div>
    <?php endif; ?>
</div>
<?php } ?>
Right now, this only prints out 'nothing scheduled' so its not quite working right.

I also tried doing a new query but then those posts won't match the tag. Maybe I could put a statement where it only prints if it equals the tag? Not sure what's the best way here. I tried looking into the theme files but I'm not very good at following the code to see what I can do. Any help would be great
  #2  
Old Nov 29, 2009, 06:22 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I'm unclear with youre statement
Quote:
I only want to show draft posts on tag pages and I only want to show drafts with that tag
can you clarify it with an example?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Nov 29, 2009, 06:34 PM
gcarson
 
26 posts · Oct 2009
Sure sorry for the confusion. So as an example, lets say the site is on concert tour dates. I use categories to classify between rock, pop, etc and tags to classify the actual tour. So as an example, a tag might be Oasis 2009 Concerts. I'm using a plugin that lets me set a date for an expiration that moves the posts to draft from published. So Each tour date has its own post and the expiration date is the concert date. So I don't want that post showing in the loop, which is my 'Up Coming Shows' area, when someone views the Oasis 2009 Concert tag page. But I do want to show past shows. I was hoping on showing them below the loop, keeping them as drafts but still showing them to the public under say 'Past Shows.' Not sure how I show draft posts below the loop?
  #4  
Old Nov 30, 2009, 04:34 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
ok, you need to build a new wp_query since 'the loop' is finished. Here is a sample you can play with that I grabed and modified a bit (from http://blog.complimedia.com/show-upc...sts-wordpress/)
HTML Code:
<?php
$my_query = new WP_Query('post_status=draft&showposts=10');
?>
<div>
    <?php
    if ($my_query->have_posts()) : while ($my_query->have_posts()) :
        $my_query->the_post();
        ?>
        <ul>
          <li>
           <?php the_title(); ?>
          </li>
        </ul>
    <?php endwhile; else: ?>
        <div>
        <ul>
          <li><?php _e('No upcoming Posts'); ?></li>
        </ul>
        </div>
    <?php endif; ?>
</div>
this is just looking for 'drafts' regardless of anything else. You might just want to build a new function so you can put all your logic init and then call that from 'Content BELOW the LOOP'
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Nov 30, 2009, 05:36 AM
gcarson
 
26 posts · Oct 2009
Thank you. I did already try something like that and like you said, it pulls all draft posts. I'll have to dig on the logic cause I think that's where I'm stuck. If I'm on the Oasis 2009 Tour tag page, I only want to pull posts that have that tag.
  #6  
Old Nov 30, 2009, 06:31 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
you just need to add the category or tag to the wp_query parameters.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #7  
Old Nov 30, 2009, 11:41 AM
gcarson
 
26 posts · Oct 2009
Well, here's my finished code that's working so far. I wanted to post it in case someone else was interested:

Code:
<?php if ( is_tag() ) { ?>

<?php $current_tag = single_tag_title("", false); ?>

<?php
$my_query = new WP_Query(array(
'post_status'=>draft,
'tag_slug__and'=>array($current_tag),
) );
?>

<div>
    <?php
    if ($my_query->have_posts()) : while ($my_query->have_posts()) :
        $my_query->the_post();
        ?>

<?php /* The Loop*/ bfa_center_content($bfa_ata['content_inside_loop']); ?>

    <?php endwhile; else: ?>
        <div>
        </div>
    <?php endif; ?>


</div>
<?php } ?>
I had some trouble getting the tag to match using single_tag_title function. It was a little tricky but this worked for me. Hope it might help out someone else.

Bookmarks

Tags
post drafts

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleted posts still showing pbennett Atahualpa 3 Wordpress theme 11 Aug 31, 2009 10:50 AM
css insert not showing individual posts bushtool New Versions, & Updating 9 Jul 15, 2009 06:54 PM
Error warning status bar page bottom JBWhite Atahualpa 3 Wordpress theme 0 Apr 21, 2009 11:53 AM
Posts showing up twice on category pages? michiganbasketball Atahualpa 3 Wordpress theme 1 Mar 12, 2009 04:56 PM
Categories not showing any posts paulae Atahualpa 3 Wordpress theme 2 Mar 10, 2009 06:35 AM


All times are GMT -6. The time now is 09:31 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.