Archived topic
Include individual PHP code in posts with or without plugin
3 replies · Started by Jasmin on March 19, 2019
Hi there,
on my older site I was using the Insert PHP plugin which helps me to display individual PHP code in blog posts. For this I have a function in my functions.php:
function pythonPage($key, $defaultVersion="couple", $indi=True)
{
$version = isset($_GET['version']) ? $_GET['version'] : $defaultVersion;
$url = "https://packlisten.pythonanywhere.com/page/".$key."/".$version;
if ($indi)
$url .= "/indi";
$success = include $url;
if (!$success) {
header('Location: https://www.packlisten.org/wartungsarbeiten/');
exit;
}
}
With the help of the plugin I call the function like this:
[insert_php]
pythonPage("Wochenendausflug");
[/insert_php]
I tried it on a separate installation with Generatepress and it works. My question is: Could I avoid this plugin and a child theme and instead get the same result with your Elements module?
Thanks in advance!
Best regards
Jasmin
Hi there,
A child theme or Code Snippets plugin is required (and better) for this.
Hooks element require the code to be certain hooks :)
Alright, thank you, Leo!
Best Regards
Jasmin
No problem :)