Beiträge von Marmeladekuchen

    [COLOR=#000000]Also das hier ist mein Code um einen String als option zu speichern, ist aber wie gesagt keine Lösung, da ich so nur jeweils einen Shortcode speichern kann. Vielleicht könnte man die strings als array mithilfe der Options API speichern. Aber um ehrlich zu sein, ich bin ziemlicher PHP nooby.

    [/COLOR][COLOR=#00008B]function[/COLOR][COLOR=#000000] question_shortcode[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]$atts[/COLOR][COLOR=#000000],[/COLOR][COLOR=#000000] $content [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#00008B]null[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#00008B] global[/COLOR][COLOR=#000000] $question_shortcode_text[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    $question_shortcode_text [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] $content[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    echo [/COLOR][COLOR=#800000]"<h2 class='question'>"[/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000] $question_shortcode_text [/COLOR][COLOR=#000000].[/COLOR][COLOR=#800000]"</h2>"[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    update_option[/COLOR][COLOR=#000000]([/COLOR][COLOR=#800000]'question_shortcode_option'[/COLOR][COLOR=#000000],[/COLOR][COLOR=#000000] $question_shortcode_text [/COLOR][COLOR=#000000]);[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000000]};
    [/COLOR][COLOR=#000000]
    add_action[/COLOR][COLOR=#000000]([/COLOR][COLOR=#800000]'save_post'[/COLOR][COLOR=#000000],[/COLOR][COLOR=#800000]'question_shortcode'[/COLOR][COLOR=#000000]);
    add_shortcode ( 'question', 'question_shortcode' );
    [/COLOR][COLOR=#000000]
    Hiermit könnte ich den string dann irgendwo ausgeben... aber eben immer nur einen

    [/COLOR][COLOR=#000000]add_filter[/COLOR][COLOR=#000000]([/COLOR][COLOR=#800000]'the_content'[/COLOR][COLOR=#000000],[/COLOR][COLOR=#800000]'testing_var'[/COLOR][COLOR=#000000]);[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#00008B]function[/COLOR][COLOR=#000000] testing_var[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000] $content [/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR][COLOR=#000000]
    $question_from_shortcode [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] get_option[/COLOR][COLOR=#000000]([/COLOR][COLOR=#800000]'question_shortcode_option'[/COLOR][COLOR=#000000]);[/COLOR][COLOR=#000000]
    $content [/COLOR][COLOR=#000000]=[/COLOR][COLOR=#000000] $question_from_shortcode [/COLOR][COLOR=#000000].[/COLOR][COLOR=#000000] $content[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#00008B] return[/COLOR][COLOR=#000000] $content[/COLOR][COLOR=#000000];[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000000]}[/COLOR]

    Ich schreibe Blogposts für mich selbst über Dinge die ich lerne. Wenn beim schreiben noch offene Fragen sind, platziere ich sie innerhalb des Blogpostings und umrahme sie mit meinem custom shortcode wie folgt:

    [frage] Offene Frage, die extrahiert und an anderer Stelle ausgegeben werden soll [/frage].

    Ich möchte, dass an einer anderen Stelle der Website aus all den Strings, die sich zwischen eines solchen Shortcodes befinden, eine dynamische Liste erstellt wird. Quasi eine "Offene Fragen Liste", die auf die jeweiligen Blogposts linkt. So kann ich dann offene Fragen im Nachhinein einfach finden und klären.

    Ich weiß aber nicht wie ich die Strings herausfiltern und an anderer Stelle ausgeben kann. Kann da jemand helfen?