Last active
January 4, 2016 07:09
-
-
Save strangerstudios/8587015 to your computer and use it in GitHub Desktop.
Shortcode to show a list of available Addon Packages based on the PMPro Addon Packages plugin. Add this code to your active theme's functions.php or a custom (pmpro-customizations) plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//shop page for add ons | |
function pmpro_addons_shortcode($atts, $content=null, $code="") | |
{ | |
ob_start(); | |
global $wpdb, $post, $current_user, $pmpro_currency_symbol; | |
?> | |
<div id="pmpro_addons"> | |
<?php | |
$count = 0; | |
// get posts | |
query_posts(array("meta_key"=>"_pmproap_price", "meta_compare"=>"!=", "meta_value"=>"", "showposts"=>-1, "orderby"=>"menu_order", "order"=>"ASC")); | |
global $wp_query; | |
if ( have_posts() ) : while ( have_posts() ) : the_post(); | |
$pmproap_price = get_post_meta($post->ID, "_pmproap_price", true); | |
if(empty($pmproap_price)) | |
continue; | |
?> | |
<div class="pmpro_addon one_third<?php if($count % 3 == 2) { ?>_last<?php } ?>"> | |
<h3><?php the_title(); ?></h3> | |
<h4><?php echo $pmpro_currency_symbol . $pmproap_price; ?></h4> | |
<a class="pmpro_btn" href="<?php echo pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->ID); ?>">Buy Now</a> | |
</div> <!-- end pmpro_addon, one_third--> | |
<?php | |
$count++; | |
endwhile; endif; wp_reset_query(); | |
?> | |
</div> <!-- end #pmpro_addons --> | |
<?php | |
$temp_content = ob_get_contents(); | |
ob_end_clean(); | |
return $temp_content; | |
} | |
add_shortcode("pmpro_addons", "pmpro_addons_shortcode"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment