Add Post Parent Field

/** * Register a Post Parent field for campaigns. * * This will allow the campaign post parent to be edited in the * campaign management page in the WordPress dashboard. */ function ed_charitable_register_campaign_post_parent_field() { $campaigns = get_posts( array( ‘post_type’…Continue reading

Move Campaign Summary Description Below Content

/** * In this example, we shuffle the order of things on the campaign page. * We move the short description and the campaign stats block to *after* * the Extended Description. */ function ed_charitable_move_description_summary_after_content() { remove_action( ‘charitable_campaign_content_before’, ‘charitable_template_campaign_description’, 4…Continue reading

Set Campaign Thumbnail Size

/** * If you want all campaign thumbnails to have the same size, you can use the * snippet below. Note that images will be hard-cropped, so part of the image * may be cropped out. * * If you…Continue reading

Enable Block Editor For Campaigns

/** * The following code will modify the way the Campaign post type * is set up to so that it uses the block editor instead of the * classic editor. */ add_filter( ‘charitable_campaign_post_type’, function( $post_type_args ) { $post_type_args[‘show_in_rest’] =…Continue reading

Set Default Highlight Colour

/** * NOTE: This snippet will not work in versions of Charitable prior to 1.2. * * Set the default colour used by Charitable. * * @return string */ function en_set_default_highlight_colour() { return ‘#123456’; } add_filter( ‘charitable_default_highlight_colour’, ‘en_set_default_highlight_colour’ );Continue reading

Add Creator Name

/** * Display the campaign creator’s name on the campaign page and in the campaign grid/list. * * @param Charitable_Campaign $campaign The campaign object. */ function ed_charitable_display_campaign_creator_name( Charitable_Campaign $campaign ) { $name = charitable_get_user( $campaign->get_campaign_creator() )->get_name(); ?> Creator:Continue reading

Add Featured Image

/** * Add a featured image to the individual campaign pages. * * @param Charitable_Campaign $campaign */ function en_add_campaign_featured_image( Charitable_Campaign $campaign ) { if ( has_post_thumbnail( $campaign->ID ) ) { the_post_thumbnail( $campaign->ID ); } } add_action( ‘charitable_campaign_content_before’, ‘en_add_campaign_featured_image’, 2 );Continue reading

Add Campaign Raised Summary

/** * Add a short summary after the donation details showing the funds raised by each campaign. */ function ed_add_campaign_stats_to_receipt( $donation ) { $campaigns = $donation->get_campaign_donations(); ob_start(); printf( ‘ %s ‘, __( ‘Campaign Stats’ ) ); foreach ( $campaigns as…Continue reading