wordpress备案选项_如何在您的WordPress帖子中添加打印机友好选项

wordpress备案选项

Often users want to print articles they find interesting. By default, WordPress itself and most WordPress themes would print your page as it is, with all the graphics, colors, and text in sidebars. In this article, we will show you how to add a printer friendly option to your WordPress posts.

用户经常想打印他们感兴趣的文章。 默认情况下,WordPress本身和大多数WordPress主题会按原样打印页面,所有图形,颜色和文本都在侧边栏中。 在本文中,我们将向您展示如何在WordPress帖子中添加打印机友好选项。

Adding a printer friendly option to WordPress posts
为什么以及何时需要WordPress帖子的打印机友好选项? (Why and When You Need a Printer Friendly Option for WordPress Posts?)

Some WordPress themes come with a separate CSS stylesheet for printing. This stylesheet is used when a user prints a page. Other WordPress themes, may not change your site’s appearance when a user prints it.

某些WordPress主题随附单独的CSS样式表进行打印。 用户打印页面时使用此样式表。 其他WordPress主题在用户打印时可能不会更改您网站的外观。

Usually this results into users printing all the images, sidebars, headers, menus, etc. Most of the time it is not very pleasant to read or look at.

通常,这会导致用户打印所有图像,侧 ,标题,菜单等。在大多数情况下,阅读或查看不是很愉快。

A typical print preview with sidebars forms all printed

You can see how your WordPress theme handles print by pressing CTRL+P when looking at a page from your site. Your browser will show print preview of your site.

当您查看站点中的页面时,可以通过按CTRL + P来查看WordPress主题如何处理打印。 您的浏览器将显示您网站的打印预览。

If your theme shows your site as it appears in the browser, then it is not handling print any differently.

如果您的主题在浏览器中显示的是您的网站,则它在处理打印方面没有任何不同。

In that case, you can use a printer friendly option on your WordPress site. It will not only make your content printer friendly, it will also encourage users to print with an on-screen print icon.

在这种情况下,您可以在WordPress网站上使用打印机友好选项。 它不仅使您的内容打印机更友好,还将鼓励用户使用屏幕上的打印图标进行打印。

We will be showing you two plugins that can add a print option to WordPress, and you can choose the one that best suits your need.

我们将向您展示两个可以在WordPress中添加打印选项的插件,您可以选择最适合您的需要的插件。

方法1:使用打印帖子和页面插件在WordPress中添加打印按钮 (Method 1: Add Print Button in WordPress with Print Post and Page Plugin)

This method is recommended for users who do not want to add code to their WordPress theme files.

对于不想向其WordPress主题文件中添加代码的用户,建议使用此方法。

First thing you need to do is install and activate the Print Post and Page plugin.

您需要做的第一件事是安装并激活Print Post and Page插件。

Upon activation the plugin will add a new menu item labeled ‘Print’ to your WordPress admin bar. Clicking on it will take you to the plugin’s settings page.

激活后,插件将在WordPress管理栏中添加一个名为“打印”的新菜单项。 单击它会将您带到插件的设置页面。

Print settings

Here you can choose the print icon size and color, text to accompany the icon, and print alignment. Optionally, you can add custom CSS that you want to include into your print template.

在这里,您可以选择打印图标的大小和颜色,图标附带的文本以及打印对齐方式。 (可选)您可以添加要包含在打印模板中的自定义CSS。

Don’t forget to click on the ‘Save and Activate’ button to store your plugin settings.

不要忘记单击“保存并激活”按钮来存储您的插件设置。

You can now visit your WordPress site and you will see a print button on your single posts.

现在,您可以访问WordPress网站,并且在单个帖子上会看到一个打印按钮。

Print button in WordPress post

However, the plugin does not automatically adds print button to your WordPress pages. You will need to add [printicon align="left"] shortcode to your WordPress pages to display the print icon on pages.

但是,该插件不会自动将打印按钮添加到您的WordPress页面。 您将需要向您的WordPress页面添加[printicon align="left"]短代码,以在页面上显示打印图标。

方法2:使用WP-Print添加打印机友好选项 (Method 2: Adding Printer Friendly Option Using WP-Print)

First thing you need to do is install and activate the WP-Print plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活WP-Print插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Settings » Print to configure plugin settings.

激活后,您需要访问设置»打印以配置插件设置。

Print Options

You can display print icon with text, just the icon, or just the text. You can choose between two icons, and you also change the text that appears with the icon.

您可以显示带有文本的打印图标,仅显示图标或仅显示文本。 您可以在两个图标之间进行选择,还可以更改与该图标一起显示的文本。

Under print options, you will be asked if you want to print comments, links, images, or videos. By default, the plugin does not print comments and videos. You can change that if you want the plugin to print comments and videos as well.

在打印选项下,将询问您是否要打印评论,链接,图像或视频。 默认情况下,该插件不打印评论和视频。 如果您希望插件也打印评论和视频,则可以更改此设置。

At the bottom of each printed post, the plugin will add a disclaimer/copyright text. By default, it will show your site’s name. You can change that to anything you want, and you can also use HTML tags inside the disclaimer field.

在每个印刷文章的底部,插件将添加免责声明/ 版权文本 。 默认情况下,它将显示您的网站名称。 您可以将其更改为所需的任何内容,也可以在免责声明字段中使用HTML标记。

Don’t forget to click on the save changes button to store your settings.

不要忘记单击“保存更改”按钮来存储您的设置。

Now comes the tricky part. The plugin will not actually add the print button into your posts. You will have to manually edit your WordPress theme files to add the button.

现在是棘手的部分。 该插件实际上不会将打印按钮添加到您的帖子中。 您将必须手动编辑WordPress主题文件以添加按钮。

Depending on your theme, you may need to add the code into single.php, page.php, archive.php, content.php, etc.

根据您的主题,您可能需要将代码添加到single.php,page.php,archive.php,content.php等中。

Locate the line in your theme template that looks like this:

在主题模板中找到如下所示的行:

<?php while (have_posts()) : the_post(); ?>

Below this line, you need to add the following code where you want to display the print button:

在此行下方,您需要在要显示“打印”按钮的位置添加以下代码:


<?php if(function_exists('wp_print')) { print_link(); } ?>

That’s all, you can now visit your website and you will be able to see the print button.

就是这样,您现在就可以访问您的网站,并且可以看到打印按钮。

Print this button

Sometimes you may have content that you do not want to be included into the print version. Simply wrap that content between [donotprint] and [/donotprint] shortcode, like this:

有时,您可能有不想包含在印刷版中的内容。 只需将该内容包装在[donotprint][/donotprint] 简码之间 ,如下所示:


[donotprint]This text will not be displayed when printing[/donotprint]

We hope this article helped you add a printer friendly option to your WordPress posts. You may also want to see our guide on how to add PDF download for posts in WordPress.

我们希望本文能帮助您在WordPress帖子中添加打印机友好选项。 您可能还想查看有关如何为WordPress中的帖子添加PDF下载的指南。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-add-a-printer-friendly-option-to-your-wordpress-posts/

wordpress备案选项

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值