Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a child theme of Twenty Twelve in wordpress. Here's where I am developing the site:

http://internalcompass.us/castle/

You'll notice the two columns of posts on the homepage. I have one labeled recent posts and one labeled favorites. In actuality, both columns are the same - recent posts organized by date. I'd like to actually create a set of posts that populate the second column, so my client can select recommended posts or her favorite posts for that column. I'd like the first column to be recent posts.

I'm hearing crickets on the Wordpress Support forum, likely because this is a pretty technical q. sooooo Any info is appreciated. I'm sure I can somehow label posts and add code to the index.html to populate the second column. I just am not yet equipped with the info to know what code to add.

Peace & thx

share|improve this question
    
if you can't help, can you recommend another site like this where i could ask my q? thx! –  kelly Jul 14 '13 at 23:26
add comment

2 Answers

I think you are hearing "crickets" because there are several component to this. You need to:

  1. Create a meta_box
  2. Save data from that meta box
  3. And build a Loop on the front

For #1 and #2:

function add_featured_meta_box() {
  add_meta_box("featureddiv", "Featured Post", "featured_post_meta_box", 'post', "side", "low");
}
add_action("do_meta_boxes", "add_featured_meta_box");

function featured_post_meta_box(){
  global $post;
  $custom = get_post_custom($post->ID);
  $featured = (!empty($custom["_featured"][0])) ? $custom["_featured"][0] : ''; ?>
<table>
    <tr>
        <td>Featured
        <td> <input type="checkbox" name="featured" <?php checked($featured,true); ?> /> </td>
    </tr>
</table><?php
}

function save_featured_meta($postid,$post){
  global $_POST;
  // set the ID to the parent post, not the revision
  $postid = (wp_is_post_revision( $postid )) ? wp_is_post_revision( $post ) : $postid;
  $post_type = get_post_type( $postid );
  if (isset($_POST['featured'])) {
    update_post_meta($postid, "_featured", true);
  } else {
    delete_post_meta($postid, "_featured", true);
  }
}
add_action('save_post', 'save_featured_meta', 1, 2);

And for #3:

$args = array(
  'post_type' => 'post',
  'ignore_sticky_posts' => true,
  'meta_query' => array(
    array(
      'key' => '_featured',
      'value' => true,
    )
  )
);
$query = new WP_Query( $args );

Barely tested. Possibly buggy. Caveat emptor. No refunds.

share|improve this answer
    
do i put the first one in functions.php and the latter in index.php? i'll try anything at this point. –  kelly Jul 15 '13 at 1:45
    
Put the first block, ideally, in a plugin file. The second block will pull your posts for the loop on the index page. –  s_ha_dum Jul 15 '13 at 2:16
add comment

A quick method would be to add a category favorite and filter the loop by only pulling posts from that category. The client could then check and un-check the favorite category on posts. Here is a rough of the args array for the loop.

$args = array(
    'category_name' => 'favorite',
    'post_type' => 'post', //or whatever post type you need
);

$posts = query_posts( $args );
if( have_posts() ): while( have_posts() ): the_post(); ?>
    <article id="post-<?php echo $post->ID; ?>" class="post type-post post-<?php echo $post->ID; ?>">
        <header class="entry-header">
            <?php echo get_the_post_thumbnail( $post->ID, 'full' ); ?>
            <h1 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        </header>
    </article>   
<?php
   endwhile;
   endif;
   wp_reset_query();
?>
share|improve this answer
    
this looks like exactly what i need to do, yes. thank you. i'm still new to this, so: does what you gave me above go in index.html in the child theme? feel free to refer me to another resource, i just haven't ever created a loop. –  kelly Jul 15 '13 at 2:03
    
yes it goes where you want the favorite loop and inside of the if statement is where you put the html so it would like something like the edit i will make above, its hard to add code to comments. –  kkemple Jul 15 '13 at 2:06
    
here are some decent resources to help you further: WP_Query and wptuts, the first is the codex for WP_Query but it shows examples of custom loops, and the second is an excellent resource for wordpress information and tutorials. hope this helps you out. If you liked my answer remember to vote it up! =] –  kkemple Jul 15 '13 at 2:13
    
thanks. i know this info is putting me on the right track, so i appreciate it. it isn't working so far, and i'm not sure why although i know it's just my own learning curve. i am reading about the loop on codex to see if i can better understand... one thing is that i didn't know where to put the code in the index.html .. i took a guess which was wrong. the two column feature, i specified in the style.css file, so it's still a mystery to me how the site will know to put the loop i'm adding now in the second column rather than the first. but not getting an error message would be a good start:) –  kelly Jul 15 '13 at 3:12
    
just saw the resources you posted. thx a lot. & i will vote. –  kelly Jul 15 '13 at 3:13
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.