How to Easily Display Code on Your WordPress Site
  • January 4

How to Easily Display Code on Your WordPress Site

Often when writing pages or tools you need an assisting plugin with the code’s piece or shortcodes. There is a bunch of tools you can use for coding right from your website using a WordPress theme or WooCommerce template.

How to show the code on the website built with WordPress theme?

In order to show the code on the page of WordPress template there is a wonderful plugin SyntaxHighlighter. You must install and activate it on the website.  Once the plugin is activated go to the plugin settings page "Parameters" (Setting) -> SyntaxHighlighter. Basically, all the settings of the plugin by default look quite reasonable. Depending on taste, you can change some of the settings from the list of Miscellaneous. Most of these settings can be overridden in the parameters of the shortcode. Now you can start using the plugin. Every piece of code is enclosed between the shortcode [sourcecode] and [/ sourcecode]. At the same time, to plug-in could not understand what the code is displayed, you must set the lang option or language. Valid values ​​are the following: php, css, xml, html, JS, Jscript, Java, bash, shell, plain, text, and so on. Or, it is much easier; you can use the tag language, for example, [php] code [/ php]. If the code is present html, then set the teobhodimo htmlscript = true. If Perevi line should be the first option is firstline = xx specifies the number of the first row. Setting highlight = x1, x2, x3 displays lines x1, x2, x3. Parameter title = "Title" displays the title of the code. With other options available on the shortcode plugin settings page.

Use shortcodes of WooCommerce themes

It would seem simple. But as long as the website is not established that the barcode reveals and interprets. Once this is established, and then instead of shortcodes on the website there will appear on a page that it should display.
17_2 Also you can use the plugin bbPress ("Shortcodes bbPress"). A few days later we decided to make some small adjustments and were horrified to find that instead of the code on the page displaying shortcodes pieces online. Quick search returned no results. People are not used on the website built with WooCommerce themes that it describes.
Do the following steps to use shortcodes of WooCommerce template:
  1. Create a secure connection to the server: "SSH/sftp and for OS Linux (OSX)” or "SSH client for Windows PuTTY" and "SSH client for Windows”.
  2. Become superuser with such shortcode #su.
  3. Go to the folder with the themes:
  • cd / chroot / httpd / var / www / wordpress / wp-content / themes / imya_temy-child / network virtual websites or WordPress theme based on the multisite;
  • cd / chroot / httpd / var / www / wp-content / themes / imya_temy-child / for the site with WordPress theme.
  1. Using the editor copy from here and add to the functions.php file before the last stitch:
/ **** Use: [bg_echo_shortcode bold = "true"] Content [/ bg_echo_shortcode] bold - prints shortcode text in Bold, if not, should be installed "false" **** /
17_3 add_shortcode ('bg_echo_shortcode', 'bg_echo_shortcode_content'); function bg_echo_shortcode_content ($ atts, $ content = null) { extract (shortcode_atts (array ( 'bold' => false, ), $ Atts)); $ prefix = ''; $ suffix = ''; if (! $ bold) { $ prefix = '<strong>'; $ suffix = '</ strong>';} return '['. $ prefix. $ content. $ suffix. ']';} This code will be printed in bold type in square brackets all that is between [bg_echo_shortcode] and [/ bg_echo_shortcode], i.e. shortcode. Brackets do not need to dial shortcode. If you want to output the content shortcode normal font, you should use the bold = false print. If you have any questions about the simple display of code on a website with WooCommerce template or WordPress theme, then you can ask them on our forum or via the Technical Support.

Did you know ?

One standard license is valid only for 1 project. Running multiple projects on a single license is a copyright violation.

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.