0

I would like to have a plugin where I could work with all post data from posts that have a selected checkbox..

To get all posts is simple with the get_posts( $args ); function...

But how to add a checkbox to every post? So that I can use the filter parameter of the get_posts( $args ); function to get only the selected ones?

Hope you understand what I mean ;)

Thanks for help!

1

Just use Post tags.

Every post in WordPress can be filed under one or more Tags. This aids in navigation and allows posts and to be grouped with others of similar content. (from Codex)

You can query posts in various ways. Most solid is of course the wp_query class. Use it like this:

// The Query
$args = array('tag' => YOUR_DESIRED_TAG_SLUG);
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
    echo '<ul>';
while ( $the_query->have_posts() ) {
    $the_query->the_post();
    echo '<li>' . get_the_title() . '</li>';
}
    echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

More on querying by tag: http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters

Also, if you don't want to waste post tags for that, you can create custom non-hierarchic taxonomy, which is, again, built-in Wordpress sollution.

  • Thanks for u quick reply! Good idea to use the post tags, I will try this! – Laurenz Glück May 5 '14 at 13:36
  • Please do. And if you'll go this route, please mark this question as answered. – Petr Cibulka May 5 '14 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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