Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to generate a printer friendly page

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
US
I just inherited a wordpress site and I dont know anything about php. I tried researching this but havnt had any luck. If someone could explain to me what's going on or point me in the right direction I would appreciate it.
I've got this code in my header.php:
<div style="text-align: right"><a href="<?=add_query_arg(array('print'=>''), $_SERVER['REQUEST_URI'])?>">View Printable</a></div>

Its obvious that this was intended to generate a print friendly version of every page, but when you click on it, it just brings up another copy of the original page as far as I can tell. something like:

Can anybody tell me what I can do to make this "view printable" work?

thanks
 
all that does is add a query string to the end of the url saying print=''

your theme will have to handle the request and produce a print friendly page.
 
Any guesses where in the theme the original developers would have intended to make this happen? I'm working totally in the dark on this one, but if I'm lucky maybe there is something somewhere that they put in but needs tweaking to make it work.

thanks
 
which theme?

there are a number of ways to sort this kind of thing out. one is to have two different css files, another is to state a media and a screen css sets in the same file (but then no point in having the print= query type), another is via a plugin.

to make it work yourself you can just edit the style.css file to create a css file for the printer (save it as a new file) and the header.php file to add in a declaration

Code:
<link rel="stylesheet" type="text/css" media="screen" href="screen.css" />
 
thanks, its beginning to make sense now.

 
The link on the wordpress page generates this link in the browser address:

I found a print.css file in the theme's folder under wp-content. Is it possible that the URL is supposed to be retrieving the page and passing it &print to tell the page to apply the print.css??

If not what is the &print supposed to be telling the browser?
 
it should simply add an href link to the html head. typically this is done in the header.php file but it may also be done via a plugin. you can tell by examining the source. remember that you should not assume that what you see on the screen is what will be printed out.
 
to make printer friendly pages you will need a second css file that is for print.

so if someone wants to print you will display the page differently that will print properly.

that is the best way to do it that i know of.

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top