• I have a whole structure of virtual pages ( custom URLs ) and use to use add_filter(‘template_include’) to load the correct template with all the associated dynamic content (not necessarily on the same database for exemple )
    using theme twenty-three, I would like to do something similar – I have design a page model directly in WP and would like to use it as my virtual page structure, and use my dynamic content through a simple replace or by using some short code in my page model.

    Any ideas ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    A custom shortcode can dynamically output any HTML content you desire. Shortcodes are PHP based, so you’re limited only by what PHP is capable of. It’s capable of a lot! For example, it could check the current request from $_SERVER and get related data from some database or resource. It could organize the data into some specific HTML layout and return the result for WP to output.

    Thread Starter solariane

    (@solariane)

    @bcworkz thanks for your answer.
    However my question was a little different : on a virtual page i.e seating on a some dynamic url, how to load the correct “model” as the template for this virtual page ? ( theme twenty-three – WP 6.3 )

    Thread Starter solariane

    (@solariane)

    to be more specific :
    I succeed in loading the “model”, but it lacks the “top” of the file ( <html><head>…<body> )

    I do this in my virtual template page :

    $modelTemplate = get_post( 766 );
    $content = apply_filters( 'the_content', $modelTemplate->post_content );
    echo $content;
    • This reply was modified 1 year, 2 months ago by solariane.
    Moderator bcworkz

    (@bcworkz)

    If you had a shortcode in your post content, applying the filter “the_content” will cause the shortcode to be expanded. Doesn’t help with header and other theme elements though.

    If you used a classic theme, I could tell you what to do, but I’m a bit lost with the block theme paradigm. I know your need a template part or few, but since block theme template parts are HTML based and not PHP, I’m unsure how to go about using them, especially from PHP code.

    You might consider asking in the theme’s dedicated support forum, or wait for someone here to come along who knows block themes better than we do.

    I’m guessing you need some React script to pull everything together, passing your PHP content to the script via inline script.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Virtual Page, model and dynamic content’ is closed to new replies.