absico on "[Plugin: Give - WordPress Donation Plugin] current form donations transaction"

ساخت وبلاگ

Hi
I am using this query to display the last 7 donation transactions.I need to modify the query so that it displays the transactions for the current form page.
$args3 = array( 'post_type'=> 'give_payment',
'posts_per_page' => 7,
);
$loop3 = new WP_Query( $args3 );
if ( $loop3->have_posts() ) :
while ( $loop3->have_posts() ) : $loop3->the_post();
$meta = get_post_meta( get_the_ID() );
$paymentmeta = $meta['_give_payment_meta'];
$getmeta = maybe_unserialize( $paymentmeta[0] );
$firstname = $getmeta['user_info']['first_name'];
$lastname = $getmeta['user_info']['last_name'];
$getdate = $meta['_give_completed_date'][0];
$date = date( "F j, Y", strtotime( $getdate ) );
$total = $meta['_give_payment_total'][0];
?>

https://wordpress.org/plugins/give/

Hi there,

I assume you're adding this into your Give single form page template via a child theme. If so, you just need to add meta key values into the query args. Here's a functioning example:

// Query 1 Argument global $post; $args = array( 'post_type' => 'give_payment', 'posts_per_page' => 3, 'meta_key' => '_give_payment_form_id', 'meta_value' => get_the_ID() ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) : ?> <h2>Output latest 3 donations with amount and date</h2> <hr/> <ul> <?php while ( $loop->have_posts() ) : $loop->the_post(); $meta = get_post_meta( get_the_ID() ); $title = $meta['_give_payment_form_title'][0]; $total = $meta['_give_payment_total'][0]; $getdate = $meta['_give_completed_date'][0]; $date = date( "F j, Y", strtotime( $getdate ) ); $gateway = $meta['_give_payment_gateway'][0]; ?> <li><strong>Donation for $<?php echo $total; ?></strong><br/> Was given on <?php echo $date; ?><br/> Through the <?php echo $title; ?> form. </li> <?php endwhile; wp_reset_postdata(); // end of Query 1 ?> </ul> <?php else : ?> <!-- If you don't have donations that fit this query --> <h2>Sorry you don't have any transactions that fit this query</h2> <?php endif; wp_reset_query();

This is based off our Snippet in our Snippet Library:
https://github.com/WordImpress/Give-Snippet-Library/blob/master/useful-queries/sample-transaction-queries.php

Let me know how that goes. Thanks!

Thank you Matt
I using it with give.php added under the root of my theme.
Now, when I use your example it shows the else result "Sorry you don't have any transactions that fit this query".

Can you paste the whole file into a Gist for me to test fully?

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 302 تاريخ : پنجشنبه 17 تير 1395 ساعت: 6:18