• Paul Roos

    (@inetroosgmailcom)


    The following PHP doesn’t work correctly in the CUSTOM HTML block ..
    <?php
    $txtstring = “<div>whatever” . “</div>“;
    print $txtstring;
    ?>
    However when I use
    $txtstring = “<div>whatever</div>”;
    it works perfectly.
    It must be something to do with the concatenation of strings within a CUSTOM HTML code block. This is a simplification as I need to concatenate several strings


    • This topic was modified 2 years, 11 months ago by Jan Dembowski. Reason: Removed NSFW as this is not that
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator threadi

    (@threadi)

    The HTML block is only for HTML code – not for PHP code as you write it here.

    What is the concrete goal of what you want to achieve with it? Maybe it can be solved better in a completely different way.

    Thread Starter Paul Roos

    (@inetroosgmailcom)

    Thanks for the reply. I want the user of the page, to type in input data and then do a database table query on the server and display the result on the website. The database table is not the standard posts etc. of which there many examples. It is a table with scheduled time slots, so it is not part of the WordPress database structure. In other words, the database table could be any available resource. At this stage, it is a lookup only. Maybe later it could be a booking and reservation of a resource i.e. update of the “external” database. Maybe a plugin would be my solution? Strange enough, the PHP code works for returning a literal constant, to the Custom code block (referring to <div>whatever</div>” ).

    • This reply was modified 2 years, 11 months ago by Paul Roos.
    • This reply was modified 2 years, 11 months ago by Paul Roos.
    Moderator threadi

    (@threadi)

    You should develop your own plugin for your project. This can realize the processing of the entered data as well as the access to the individual database tables. For the integration in the frontend you could use shortcodes, which could also control the output. Or you could develop your own Gutenberg blocks, if you want it to look “nice” for editors.

    Thread Starter Paul Roos

    (@inetroosgmailcom)

    Thank you. I was looking for a “quick” solution.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP problem when using Gutenberg CUSTOM HTML block’ is closed to new replies.