[Resolved] Include individual PHP code in posts with or without plugin

Home Forums Support [Resolved] Include individual PHP code in posts with or without plugin

Home Forums Support Include individual PHP code in posts with or without plugin

  • This topic has 3 replies, 2 voices, and was last updated 4 years ago by Leo.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #842994
    Jasmin

    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

    GeneratePress 2.2.2
    GP Premium 1.7.8
    #843493
    Leo
    Staff
    Customer Support

    Hi there,

    A child theme or Code Snippets plugin is required (and better) for this.

    Hooks element require the code to be certain hooks ๐Ÿ™‚

    #844122
    Jasmin

    Alright, thank you, Leo!

    Best Regards
    Jasmin

    #844692
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.