Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Show Posts For Sale
- * Generates a list of posts that are set for sale using myCRED.
- * @version 1.0
- */
- add_shortcode( 'posts_for_sale', 'mycred_pro_show_posts_for_sale' );
- function mycred_pro_show_posts_for_sale( $atts, $content = '' ) {
- $args = array(
- 'post_type' => 'post',
- 'post_status' => 'publish',
- 'meta_query' => array(
- array(
- 'key' => 'myCRED_sell_content',
- 'compare' => 'EXISTS'
- ),
- array(
- 'key' => 'myCRED_sell_content',
- 'value' => '"status";s:7:"enabled"',
- 'compare' => 'LIKE'
- )
- )
- );
- $for_sale = new WP_Query( $args );
- ob_start();
- if ( $for_sale->have_posts() ) {
- ?>
- <ul>
- <?php
- while ( $for_sale->have_posts() ) {
- $for_sale->the_post();
- ?>
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
- <?php
- }
- ?>
- </ul>
- <?php
- }
- else {
- ?>
- <p>No posts are for sale at the moment.</p>
- <?php
- }
- $content = ob_get_contents();
- ob_end_clean();
- wp_reset_postdata();
- return $content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement