Often times you may want to display donor information on your website from Give. The following will demonstrate how to do this using Give’s core classes. Keep in mind, not all donors want their information displayed publicly.

Getting Donors from Your Give Database

The key to getting donors from your database is using the Give_Donors_Query class.

Get the latest 3 Give Donors

 *  QUERY 1: Basic Example
 *  This query outputs the latest 3 transactions
 *  with the amount and date
// Query 1 Argument
$args = array(
	'number' => 3

$loop1 = new Give_Payments_Query( $args );
$loop1 = $loop1->get_payments();

if ( $loop1 ) {
	<h2>Output latest 3 donations with amount and date</h2>
		foreach ( $loop1 as $payment ) {

			<li><strong>Donation for $<?php echo esc_html( $payment->total ); ?></strong><br/>
				Was given on <?php echo esc_html( date( "F j, Y", strtotime( $payment->date ) ) ); ?><br/>
				With the <?php echo esc_html( $payment->gateway ); ?> Payment Gateway
} else {
	<!-- If you don't have donations that fit this query -->
	<h2>Sorry you don't have any transactions that fit this query</h2>

Understanding all the data you can Query for Donors

Often the easiest way to query data is to see a dump of the data to be able to customize the query. In the above snippet you pulled the name for each donor with $donor->name object/key.

The following snippet will similarly query the Give Donor Object, but instead of returning 20 Donors, it will return one donor, and all of the various attributes of that object.

Note: Give’s Donor Wall is a method for displaying donors on the front end of the site that respects the “anonymous” status of donations. The following tutorial will display donors regardless of “anonymous” status of the donation.

Get all data to use in Donor Queries

 *  TESTING: Outputs all post meta
 * This section outputs all the custom fields for your reference
 * Just set the $testing variable to true
$testing = false;

if ( $testing == true ) {
	$testquery = new Give_Payments_Query( array( 'number' => 1 ) );
	$payments       = $testquery->get_payments();
	if ( $payments ) {
		foreach ( $payments as $payment ) {
			$meta = give_get_meta( $payment->ID );
			<div style="background: #555; color: white; padding: 2rem;">
				<h3>Test Data</h3>
				<p>The following outputs all the "give_payment" fields for you to reference in building out your
					donation list</p>
				<p><?php var_dump( $meta ); ?></p>


That gives you a starting point to pull any data you’d like for Donors from your Give database.