- This topic has 12 replies, 5 voices, and was last updated 4 years, 7 months ago by Mike.
February 21, 2017 at 11:31 am #282080John
I am building a couple of pages that are tutorials on coding (for Arduino). I am looking for a way to have the coding examples wrapped in a coding-type window. I have tried the “SyntaxHighlighter Evolved” plugin, but was having troubles with it.
We did notice on the Optimizing GeneratePress from July 2016, there are some coding examples which is exactly what we are looking to do. Was this a plugin to do this?
Can anyone suggest another tool that could be useful for including source code on to a page?
Thanks… JohnGP Premium 1.2.94February 21, 2017 at 3:23 pm #282147LeoStaffCustomer Support
You are talking about the code on this page? https://generatepress.com/fastest-wordpress-theme/
Looks like it’s done with this: https://github.com/google/code-prettifyMarch 1, 2017 at 12:14 pm #285767Markus
I would also like to display code on my homepage but, like John, I would really like to use “SyntaxHighlighter Evolved”.
Frankly, I haven’t even tried installing the plugin yet. Anyway, should it be compatible with GP Premium in principle? Also, I noted the following warning message here:
Make sure your theme’s footer.php file has <?php wp_footer(); ?> somewhere inside of it, otherwise the plugin won’t be able to do it’s thing.
Could you walk me through how to do that in WordPress with GP activated? I am not quite sure where to start. I faintly remember from a previous problem that one has to be careful about how to go about these things in order not to have the line removed when the GP Premium plugin is next updated.
If you know another/better WordPress plugin to highlight code syntax (for R) that reconciles better with GP, please free to let me know and I’ll consider it as an alternative, particularly if “SyntaxHighlighter Evolved” does not work well with GP, for one reason or another.
MarkusMarch 1, 2017 at 1:05 pm #285788Markus
Me again 🙂 I have now actually given Code Prettify a try and installed it. Anyway, it does not seem to be working with GP premium. Is that possible? Is it generally hard to use cody syntax highlighter tools with GP premium?
P.S.: This here is why I think GP premium may cause the trouble.March 1, 2017 at 1:53 pm #285814LeoStaffCustomer Support
The plugin you tried is actually different than this one right here: https://github.com/google/code-prettify which is developed by Google.
Definitely confusing as they have the same name…Can you give that one a shot?
You can download it from Github (Clone or download) then upload it through the plugin page.
Let me know if this helps 🙂March 1, 2017 at 2:00 pm #285815Markus
unfortunately, that attempt ended with an error message:
Installing Plugin from uploaded file: code-prettify-master.zip
Unpacking the package…
Installing the plugin…
The package could not be installed. No valid plugins were found.
Plugin install failed.March 1, 2017 at 2:05 pm #285818LeoStaffCustomer Support
ahh my bad. It’s actually not a plugin. Never used it before myself…
Checkout their Doc page: https://github.com/google/code-prettify/blob/master/docs/getting_started.md
Let me know.March 1, 2017 at 2:11 pm #285821Markus
So when writing a blog post including code, I should just add this line
at the top (in the text tab)? Is that it?March 1, 2017 at 2:35 pm #285831LeoStaffCustomer SupportMarch 1, 2017 at 2:43 pm #285833LeoStaffCustomer SupportMarch 1, 2017 at 3:16 pm #285849Markus
Actually, now it is my time to scratch something. I had somehow assumed that the code would be highlighted already in the visual tab. After saving the draft and previewing the post, the Code Prettify plugin actually worked :/
I have also tried entering the script in wp_head, as you suggested, and that also worked. So now people having the same problem as me will find two solutions in this thread… there is always a silver lining, I guess 😉
Anyway, I am now thinking it is somehow ‘redundant’ to load the script on every page, which I guess both solutions do. It seems to me that being able to load the script only for posts where I actually need to highlight code would be more elegant.
I am trying to tweak Advanced Custom Fields as described here to do the job, but I am not sure where to add
<?php the_field(‘header_script'); ?>and
<?php the_field(‘footer_script'); ?>(point 6 in method three). I have tried going through GP Hooks but could not get it to work. Perhaps you could give it a try and let me know? Or couldn’t this be implemented through GP Hooks?March 1, 2017 at 8:29 pm #285937Lyle
Hi John, Markus, Leo,
I tried pretty much every plugin of this type from the WP repo and this is the plugin that I now use and it works very nicely:
Here is a page from my site with it in action 🙂
Tutorials and tips for GeneratePress, WP Show Posts, WordPress and ElementorOctober 20, 2017 at 7:43 am #406960Mike
Thanks Lyle, this is exactly what I have been looking for. I was using embeds from github and they kept being removed from my blog posts.
- You must be logged in to reply to this topic.