• Firstly, excellent plugin. Does exactly what I want, apart from the ability to show custom fields and those in custom post types.

    There are a couple of threads asking about this, but there is a very simple solution using WordPress filters.

    After line 403 of wp-post-to-pdf-enhanced.php I’ve added the following:

    $html.= apply_filters('before_pdf_content', '');

    This sets up a filter which can be used by themes to insert their own content at this point.

    In my theme functions.php I have added the following:

    function my_pdf_custom($text) {
    	if ('article' == get_post_type() ) {
    		$author_text = get_post_meta(get_the_ID(), '_author_text', true);
    		if ($author_text) {
    			$text.= "<h2>By " . $author_text . "</h2>";
    		}
    	}
    	return $text;
    }
    
    add_filter('before_pdf_content', 'my_pdf_custom');

    This checks to see if we’re generating a pdf for my custom post type ‘article’, and if so adds my ‘author_text’ information to the output.

    I only need it in my case to show this just before the content but other filters could go after the content, before or after title etc.

    Could you look at building these filters into the plugin?

    You can see it working on the articles here: http://framescinemajournal.com

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Custom fields and custom post types’ is closed to new replies.