• Resolved yngwi

    (@yngwi)


    Hi, I’m looking for the best way to integrate some external data into WordPress without it having a representation or any data stored in the WordPress database. I have currently tried to add custom post type that is hidden from the menu where I load the list of external content, the “custom posts” on the “Archive” template. What I’m having problems with is creating the “single” view for these virtual custom posts as of course WordPress doesn’t find anything in its database for an URL like https://example.com/virtual_post_type/external_id and just displays 404. Does anyone know of other ways to achieve this or how to tell WordPress to just display the single post template for this and let me handle the rest? I could of course also just use a custom page template for this data and add the individual “posts” as query parameter like https://example.com/virtual_post_type?id=external_id. Any input is welcome! Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • A page using a custom page template that receives a parameter from its URL seems to be way to go:

    https://example.com/custom-page/?external_id=1

    When no parameter is received:

    https://example.com/custom-page

    …you could conditionally show a list of URLs, a URL for each external_id:

    <h1>Choose an ID</h1>
    
    <ol>
        <li><a href="https://example.com/custom-page/?external_id=1">View ID #1</a></li>
        <li><a href="https://example.com/custom-page/?external_id=2">View ID #2</a></li>
        <li><a href="https://example.com/custom-page/?external_id=3">View ID #3</a></li>
        <li><a href="https://example.com/custom-page/?external_id=4">View ID #4</a></li>
        <li><a href="https://example.com/custom-page/?external_id=5">View ID #5</a></li>
    </ol>
    Thread Starter yngwi

    (@yngwi)

    Yes, that’s what I now settled on doing, thank you for your input and confirming my chosen path!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“Virtual” Custom Post Type’ is closed to new replies.