Embed Docs into a Course

Add this snippet to your site

function show_specific_post_content_shortcode($atts) {
    // Shortcode attributes, expects 'id' parameter
    $attributes = shortcode_atts(array(
        'id' => '', // Default is an empty string
    ), $atts);

    // Get the specified post ID's content if provided, otherwise return nothing
    if (!empty($attributes['id'])) {
        $post = get_post($attributes['id']);
        if ($post) {
            // Apply the_content filter to process shortcodes and display HTML correctly
            return apply_filters('the_content', $post->post_content);
        }
    }

    return 'Post not found.'; // Return this if no post ID is provided or post is not found
}
add_shortcode('show_post_content', 'show_specific_post_content_shortcode');

This allows you to put the post ID into the shortcode and pull a doc into a lesson for example. You’d use it like this [show_post_content id=”123″]

Play the Video #

Step-By-Step Instructions #

To embed an existing document or Standard Operating Procedure (SOP) into a lesson or topic within your course, follow these step-by-step instructions:

  1. Navigate to the Lesson or Topic Creation Page:
    • Start by going to the section of your course management platform where you can create or edit a lesson or topic.
  2. Name Your Lesson or Topic:
    • Enter a name for your lesson or topic in the designated field. For demonstration purposes, you can name it “Test” or choose a name that reflects the content you’re embedding.
  3. Insert the Shortcode:
    • In the content area or the specific field where you can add text, type a forward slash (/) followed by the word “shortcode” to initiate the insertion of a shortcode.
    • Click on the option to insert a shortcode when it appears.
  4. Input the Shortcode Template:
    • In the field provided for the shortcode, paste or type the following template:
    • [show_post_content id=”123″]
    • This template includes a bracketed command show_post_content with an id attribute. You will replace the “123” with the specific ID of the document you want to embed.
  5. Find the Document ID:
    • Navigate to the document or SOP you wish to embed in your lesson or topic. This might involve going to a “Docs” section or an “Edit Docs” page.
    • Once you’re viewing the document you want to embed, look at the URL in your browser’s address bar. You should see a parameter that looks something like post=3930. The number after post= is the ID of the document.
    • Copy the ID number.
  6. Replace the Placeholder ID with the Actual ID:
    • Go back to where you were inputting the shortcode in your lesson or topic.
    • Replace the quotation marks in the shortcode template with the actual ID number of your document. For example, if the ID is 3930, your shortcode should look like this:
    • [show_post_content id=”123″]
  7. Publish or Update the Lesson or Topic:
    • Once you have inserted the correct shortcode with the ID of the document you want to embed, proceed to publish or update your lesson or topic.
  8. Preview the Embedded Document:
    • After publishing or updating, view the lesson or topic on the front end of your course platform to ensure that the document is correctly embedded.
    • The content from the specified document should now appear within the body of your lesson or topic.
  9. Troubleshooting:
    • If the document does not appear as expected, double-check the shortcode and the ID number for accuracy. Ensure there are no typographical errors and that the document ID is correct.
    • Some platforms may require additional steps or specific permissions to embed content. Consult your platform’s documentation or support resources if you encounter issues.

Unlock These Courses And More!

Create a free account or log in to access our courses and other free content just like it!