registerguard / baffin

RG forms
0 stars 0 forks source link

Update to not show protected posts #5

Closed robertdenton closed 10 years ago

robertdenton commented 10 years ago

Resources:

robertdenton commented 10 years ago

My proposal, need to clear with @mhulse

<!-- [BEGIN] The loop -->
<!-- For notes on method, see: -->
<!-- http://digwp.com/2011/05/loops/#wp-query -->
<!-- http://codex.wordpress.org/Class_Reference/WP_Query#Password_Parameters -->
<?php
    $sans_protected = new WP_Query(array('has_password' => false));
    while($sans_protected->have_posts()) : $sans_protected->the_post(); 
?>

    <h1><a href="<?=the_permalink()?>"><?=the_title()?></a></h1>
    <div class="form-category"><?=the_category()?></div>

<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<!-- [END] The loop -->
mhulse commented 10 years ago

Here's how I'd write that:

<?php // https://github.com/registerguard/baffin/issues/5 ?>

<?php $sans_protected = new WP_Query(array('has_password' => FALSE)); ?>

<?php while ($sans_protected->have_posts()): ?>

    <?=$sans_protected->the_post()?>

    <h1><a href="<?=the_permalink()?>"><?=the_title()?></a></h1>
    <div><?=the_category()?></div>

<?php endwhile; ?>

<?php wp_reset_postdata(); ?>

Add css classes as needed.

I avoid single line <?php ... because I think it's less readable.

I don't use HTML comments for things that relate to PHP, because they will show when viewing the "generated" source and give prying eyes an idea as to what our PHP is doing.

Thanks!

robertdenton commented 10 years ago

Added. Closing.