Home / Admin / Hide Campaign Meta (Author, Date, Comments)
Duplicate Snippet

Embed Snippet on Your Site

Hide Campaign Meta (Author, Date, Comments)

Automatically hides theme-generated meta information from campaign pages (only for Charitable Pro 1.8.13).

Code Preview
php
<?php
<?php
/**
 * Hide Campaign Meta (Author, Date, Comments)
 *
 * Automatically hides theme-generated meta information from campaign pages.
 * Detects your theme and applies appropriate CSS selectors.
 *
 * Compatible with 12+ themes including:
 * - Astra, Kadence, OceanWP, Divi, Hello Elementor
 * - GeneratePress, Neve
 * - Twenty Twenty-Four, Twenty Twenty-Three, Twenty Twenty-Two
 * - Twenty Twenty-One, Twenty Twenty, Twenty Nineteen
 * - And many more via fallback selectors
 *
 * @package   Charitable Pro
 * @version   1.0.0
 * @see       https://wpcharitable.com/docs/hide-campaign-meta/
 *
 * INSTALLATION:
 * 1. Copy this entire code
 * 2. Add to functions.php, child theme, or Code Snippets plugin
 * 3. Visit a campaign page to verify meta is hidden
 * 4. Customize options below if needed
 */
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * ========================================
 * STEP 1: Enable the Feature
 * ========================================
 */
add_filter( 'charitable_enable_campaign_meta_hiding', '__return_true' );
/**
 * ========================================
 * OPTIONAL CUSTOMIZATIONS
 * ========================================
 * Uncomment and modify sections below as needed
 */
/*
 * Add Custom CSS Selectors
 *
 * Use this if your theme isn't supported or you need to hide additional elements.
 *
 * How to find selectors:
 * 1. Visit a campaign page
 * 2. Right-click on the meta element (author/date) → Inspect
 * 3. Look for the CSS class or ID in the HTML
 * 4. Add it to the array below
 */
/*
add_filter( 'charitable_campaign_meta_selectors', function( $selectors ) {
	// Add your custom selectors here
	$selectors[] = '.my-custom-meta-class';
	$selectors[] = '.another-meta-wrapper';
	return $selectors;
});
*/
/*
 * Disable for Specific Campaign Types
 *
 * Hide meta on parent campaigns but show it on child/ambassador campaigns.
 */
/*
add_filter( 'charitable_hide_meta_for_campaign', function( $hide, $campaign_id ) {
	$campaign = charitable_get_campaign( $campaign_id );
	// Don't hide for child campaigns (fundraiser pages)
	if ( $campaign && $campaign->is_child_campaign() ) {
		return false;
	}
	return $hide;
}, 10, 2 );
*/
/*
 * Disable for Specific Campaigns by ID
 *
 * Exclude certain campaigns from meta hiding.
 */
/*
add_filter( 'charitable_hide_meta_for_campaign', function( $hide, $campaign_id ) {
	// Campaign IDs to exclude (keep meta visible)
	$exclude_campaigns = array( 123, 456, 789 );
	if ( in_array( $campaign_id, $exclude_campaigns ) ) {
		return false;
	}
	return $hide;
}, 10, 2 );
*/
/*
 * Enable Only for Active Campaigns
 *
 * Show meta on expired/inactive campaigns.
 */
/*
add_filter( 'charitable_hide_meta_for_campaign', function( $hide, $campaign_id ) {
	$campaign = charitable_get_campaign( $campaign_id );
	// Only hide for active campaigns
	if ( $campaign && ! $campaign->is_active() ) {
		return false;
	}
	return $hide;
}, 10, 2 );
*/
/*
 * Enable Debug Mode
 *
 * Shows red borders around elements instead of hiding them.
 * Useful for troubleshooting or verifying what's being targeted.
 */
/*
add_filter( 'charitable_campaign_meta_hiding_debug', '__return_true' );
*/
/*
 * Enable Debug Mode for Admins Only
 *
 * Only show debug borders when logged in as admin.
 */
/*
add_filter( 'charitable_campaign_meta_hiding_debug', function() {
	return current_user_can( 'manage_options' );
});
*/
/*
 * Force Cache Refresh
 *
 * Clear cached CSS after theme update or when testing changes.
 * Visit: yoursite.com/?refresh_meta_cache=1 (as admin)
 */
/*
add_action( 'init', function() {
	if ( current_user_can( 'manage_options' ) && isset( $_GET['refresh_meta_cache'] ) ) {
		delete_option( 'charitable_campaign_meta_cache' );
		wp_safe_redirect( remove_query_arg( 'refresh_meta_cache' ) );
		exit;
	}
});
*/
/*
 * Adjust Cache Duration
 *
 * Default: 30 days. Set shorter if theme updates frequently.
 */
/*
add_filter( 'charitable_campaign_meta_cache_duration', function() {
	return 7 * DAY_IN_SECONDS; // Cache for 7 days
});
*/
/**
 * ========================================
 * TROUBLESHOOTING
 * ========================================
 *
 * Meta Still Showing?
 * 1. Clear browser cache (Ctrl+Shift+R)
 * 2. Try force cache refresh (see above)
 * 3. Enable debug mode to see what's being targeted
 * 4. Add custom selectors for your theme
 * 5. Check https://wpcharitable.com/docs/hide-campaign-meta/
 *
 * Layout Looks Broken?
 * 1. Disable feature temporarily
 * 2. Use per-campaign filter to exclude problematic campaigns
 * 3. Report issue with theme name and screenshot
 *
 * Works on Some Themes, Not Others?
 * - This is normal! Add custom selectors for unsupported themes
 * - Or submit your theme selectors to help expand the database
 *
 * Support:
 * https://wpcharitable.com/support/
 */

Comments

Add a Comment