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

Getting Donors from Your GiveWP Database

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

Get the latest 3 GiveWP Donors

 *  QUERY 1: Basic Example
 *  This query outputs the latest 3 transactions
 *  with the amount and date

// Query 1 Argument
$args = array(
	'number' => 3,

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

if ( $payments_loop ) {
	foreach ($payments_loop as $donation) {
		<!-- If you DO have donations that fit this query -->
		<p class="donation-date">date );?></p>
		<p class="donation-amount">subtotal );?></p>
	<!-- 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 GiveWP Donor Object, but instead of returning 20 Donors, it will return one donor, and all of the various attributes of that object.

Note: GiveWP’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 = true;

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>


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