Skip to content

Rendering plugin data #2182

Open
Open

Description

@jonathanbossenger
No description provided.

Activity

  1. moved this from 👋 Ready to Create to 🚧 Drafts in Progress in LearnWP Content - Developmenton Feb 5, 2024
  2. changed the title [-]Rendering information[/-] [+]Rendering plugin data[/+] on Feb 11, 2024
  3. moved this from 🚧 Drafts in Progress to 👋 Ready to Create in LearnWP Content - Developmenton Feb 11, 2024
  4. jonathanbossenger commented on Feb 11, 2024

    @jonathanbossenger
    CollaboratorAuthor

    Initial draft script:

    # Rendering Information
    
    When developing custom plugins, there may be instances where you need to render information on the front end of a WordPress site.
    
    In this lesson, you'll learn about some common ways to implement rendering of information from a plugin.
    
    ## Theme template
    
    As you learned in the [What is a plugin](01-what-is-a-plugin.md) lesson, a WordPress plugin adds new features or functionality to a WordPress site.
    
    The most common way to display information from WordPress is to use specific theme template files.
    
    For example, in the bookstore example plugin, you created a custom post type for books.
    
    You could then create custom templates like an `archive-book.html` or `single-book.html` in the theme to render the books archive or an individual book's information.
    
    Depending on what you are working on will determine how you implement this:
    
    - If you're working on a custom site that you have full control over, and you're also building a custom theme, you can add these templates to the theme
    - If you're working in customising an existing theme, you can add these templates to a child theme
    
    Developing custom templates is outside the scope of this lesson, but you can learn more about this in the [Theme Developer Handbook](https://developer.wordpress.org/themes/), and more specifically the [Templates](https://developer.wordpress.org/themes/templates/) section of that handbook.
    
    You can also watch the "An introduction to developing WordPress themes" module in the Beginner Developer Learning Pathway as well as the Intermediate Theme Developer Learning Pathway to learn more about developing custom themes and theme templates. 
    
    ## Custom Templates in the Site Editor
    
    It is also possible to create a custom template in the Site Editor. 
    
    When you register a custom post type, the Site Editor offers you the option to create templates for that custom post type.
    
    For example, with your book custom post type enabled, navigating to the Templates section in the Site Editor and clicking Add New Template will give you options to add new archive and single item templates for your book.
    
    You can then use the Template Editor to create and edit these templates.
    
    For example, with a Single Book template created and saved, viewing the book post type in the front end of the site will use the Single Book template to render the book information.
    
    ## Custom Blocks
    
    Another way to render information from a plugin is to use custom blocks.
    
    Blocks are modular components used to compose and format content in a WordPress site, and are used to create rich and flexible layouts for post, pages, and just about any other WordPress content.
    
    You could develop a custom block to render information from your plugin, which the users of your plugin could then implement in their own posts, pages, or custom templates.
    
    You will learn more about blocks in the Introduction to WordPress Blocks section of the Beginner Developer Learning Pathway.
    
  5. moved this from 👋 Ready to Create to 🚧 Drafts in Progress in LearnWP Content - Developmenton Mar 11, 2024
  6. removed their assignment
    on Jan 9, 2025
  7. melbos commented on Aug 6, 2026

    @melbos

    Picking up the draft above, I filled out the remaining sections (Custom Templates in the Site Editor, Custom Blocks, Custom Shortcodes, Template Tags, Hooking into Post Content) and added a code example to each, all using the same bookstore/book CPT from the earlier draft. A couple of small corrections along the way: the classic theme-template section uses .php rather than .html (that's the block-theme/Site Editor convention, covered in its own section below), and the shortcode example uses meta_query instead of the older top-level meta_key/meta_value.

    Full script: https://github.com/melbos/intermediate-plugin-developer-lessons/blob/main/lessons/13-rendering-plugin-data.md

    Happy to adjust scope, trim, or split this into two lessons if that fits the pathway's outcome-count convention better. Flagging that as an open question rather than a decision I made unilaterally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions