Custom Margins for LearnDash Certificates

Updated 2 years ago
by Dave Warfel

Are you having trouble with placement of shortcodes or other content on your LearnDash certificate? LearnDash adds a default margin on all four sides of their certificates. But they also provide us with a simple piece of code we can use to adjust them, or set them all to 0.

Use the following code to set all margins to 0. You can adjust the margin on each of the four sides by changing the 0 to any value you’d like.

This will definitely work with default LearnDash certificates built using the core LearnDash plugin. It’s unsure whether or not it also works when using the Certificate Builder add-on.

add_filter(
	'learndash_certificate_params',
	function ( $tcpdf_params = array(), $post_id = 0 ) {

		if ( ( isset( $tcpdf_params['margins'] ) ) && ( is_array( $tcpdf_params['margins'] ) ) ) {
			$tcpdf_params['margins']['top']    = 0;
			$tcpdf_params['margins']['right']  = 0;
			$tcpdf_params['margins']['bottom'] = 0;
			$tcpdf_params['margins']['left']   = 0;
		}
 
		// Always return $tcpdf_params
		return $tcpdf_params;
	},
	30,
	2
);

All CSS code should either be placed in a child theme’s main CSS file (typically style.css), or the Additional CSS area of the WordPress Customizer.

How to Add CSS to Your Site

Forum Rules

Be Kind & Patient

We’re here to learn and/or help each other. Please don’t be mean, rude, or condescending. Treat all members the way you should be treating dogs and your elders—with the utmost love & respect.

External Links

✅ Other websites that add value, help solve problems & contribute to the discussion. ❌ Affiliate links are prohibited. (Site owners may use affiliate links to help support the site.)

Promotion

✅ You may promote your own products/services if they are relevant to an existing discussion. You must disclose your relationship with the product(s).
❌ You may not create new posts simply to promote your products.

Non-LearnDash Topics

❌ General (free) Forum: Only LearnDash-specific topics are allowed.
✅ Premium Forums: You are allowed to post other questions tangentially related to LearnDash. Please use the appropriately named forum. If it doesn’t exist, use the “LearnDash Integrations” forum.

Our Right to Remove

We reserve the right to remove any content, at any time, for any reason. We can also merge one post with another. We will exercise caution when removing content and always try to provide an explanation.