Home Français A propos Contact rss
WordPress from the beginning
Sharing some discoveries about WordPress
 

Print this article button

This function enables printer-friendly versions of your posts, i.e. keeping the central part, showing the body copy only. The plugin I tried is wp print

Installation

Classic installation method here. It is delivered with a few options:

Options du plugin wp-print

wp-print plugin options

Integration

you get the print icon adding the code <?php if ( function_exists(‘print_link’ ) print_link(); ?> in single.php for example.

Incompatibility with the zdmultilang plugin

My problem was to make it work with the zdmultilang plugin

Indeed there seems to be an incompatibility at url level, that inhibits wp-print when zdmultilang adds its /fr at the beginning of the url.

I bypassed this problem changing three lines of the wp-print plugin, in the wp-print.php file, print_link() function:

// global $id;
global $id, $CurrentLanguagePermalink; 
 
// $using_permalink =get_option('permalink_structure');
$using_permalink = false;
 
// $print_link = get_permalink();
$print_link = "/cms/wordpress/?p=$id&amp;lang=$CurrentLanguagePermalink";

Explanation

The aim is to keep your blog’s clean urls, but to add a “dirty” link on the printer’s icon.

If your blog is at your site’s root, the 3rd line would read:

$print_link = "/?p=$id&amp;lang=$CurrentLanguagePermalink";

This trick only works with posts, I didn’t bother to look any further as I didn’t need it!

Last, here’s what integration in my theme looks like:

<?php if(function_exists(‘print_link’)) { ?>
<img src=”/cms/wordpress/wp-content/themes/inove/icons/imprimante16.png” align=”texttop” alt=”print” />
<a href=”/cms/wordpress/?p=<?php echo $post->ID; ?>&lang=<?php echo $CurrentLanguagePermalink; ?>&print=1″><?php _e(‘print’, ‘inove’); ?></a>
<?php } ?>

Spread this post over the world!

Share/Bookmark

How did you like this post?

Please don't go without leaving a mark!
6 vote(s) 1 Etoile2 Etoiles3 Etoiles4 Etoiles5 Etoiles Loading ... Loading ...

Reactions

comments 2 comments
  1. March 5th, 2009 at 17:50

    Content d’avoir pu te rendre service, et merci pour les encouragements :O)

    Like or Dislike: Thumb up 2 Thumb down 2

  2. Aude
    March 5th, 2009 at 14:48

    Bonjour

    Merci pour cet article qui a résolu mon problème entre zdmultilang et wp-print !

    Bravo, continue, toutes tes infos et tes conseils nous aident bien !

    Like or Dislike: Thumb up 1 Thumb down 1

Top
Choisissez vos widgets

Plugin

How to add a plugin??

About this post

  • About this weblog

    "WordPress From the beginning" is written by a French web developer and teacher currently based in Switzerland.

    Originally planned in french, both blog and its functions were developped in this language. This explains why not all functions are available in the English version.

    However, new translated articles are regularly posted for use by the wordpress' web community.

Wordpress from the beginning is a production of Woodymood
Performance Optimization WordPress Plugins by W3 EDGE