when a shortcode is defined, he has to return HTML output. then to allow the theme to customise data presentation, you can do something like that :
add_shortcode("form_step_2", function ($attr, $content, $tag) {
// preparing data
//...
// result to display
$template_name = "form/step_2";
// search the file wp-content/themes/twentytwenty/my_plugin/form/step_2.php
$template = locate_template("my_plugin/$template_name.php");
// if the file doesn't exist in the theme
if ("" === $template) {
// use the plugin file wp-content/plugins/my_plugin/templates/form/step_2.php
$template = __DIR__ . "/templates/$template_name.php";
}
ob_start();
require $template;
$output = ob_get_clean();
return $output;
});
Related Posts:
- Custom user roles
- WordPress next post by ajax call on button click
- Create API’s for custom-post types & custom queries using REST or Graphql
- How can i redirect click to new admin page not to edit screen in post table
- custom post type and user post count shortcode
- How can I assign multiple parents to CPT?
- How to limit the number of custom posts certain users can publish in WordPress using php script?
- Remove plugin settings from post creation page for a user role
- Metabox collapsed by default
- Custom post type defaults to index.php for archive page
- customize Dokan multi vendor: how can i set every Dokan as child of another dokan?
- Is it possible to create 2 unique titles for an Events custom post type: Upcoming Events and Past Events?
- Querying posts that don’t have a certain key value or don’t have the key
- What is WordPress Way to Add Content Blocks to Post and Reference them as Many to One Relationship?
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- wp delete duplicate entries of custom post types every 15 minutes
- Set a Default CPT taxonomy by taxonomy id
- Adding specific custom fields (images) to post excerpt
- Displaying posts inside table having issues
- Getting 404 on child page with pre_get_posts() on custom posts
- My post loop needs to have 8 different post templates
- pricefilter without WooCommerce
- Automatic Set Category For A Custom Post Type
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Publish metabox postition?
- Need folder for CPT templates for eg: single-{post_type}.php
- Building Link List for Custom Tax
- CPT: multiple loops with different terms
- How to add custom supports for custom post types?
- Stored meta from attachment, video length?
- Help Adding filter to Add Media button for custom post type
- Limit posts per page depending on the size of a div?
- In the admin, how can you list thumbnails instead of titles for a custom post type?
- Update/publish custom post type with jQuery?
- Attempting to create custom “post” template, getting a 500 internal server error
- Is there a best practice, or typical way to do AJAX updating for data on a custom admin screen or post.php?
- Delete Post by User
- WordPress deletes custom posts instead of trash them
- save_post affect creation and deletion
- Link two different post using there post_id in post meta
- Permanent Custom Post Type
- Multiple WordPress Sites, Same Database but Filtered Content
- Help with Travel Guide Setup
- connect users to Custom post types
- Set a static page as a user profile page?
- creating a custom post template
- Custom Pagination based on Custom Post Type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- WordPress query posts by custom post type not workng
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Change Background Color For CPT Template
- How to keep a CPT stick to specific position?
- One Post with different content, depending on a Page
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Custom Post Type
- Cant edit custom post type in WordPress dashboard
- Child Theme problems
- Static front page has page url not site url
- Registering an optional custom post type from a plugin
- WP_Query for CPT with filter by another WP_Query
- Add role privileges of the custom post type
- Advanced Custom Fields – Add Field to Specific Page [closed]
- How do I get a nested query to only display content that the main query outputed
- creating different edit screens for different roles
- Add category slug as class attribute in a link array
- Sort by Custom Post Type (Multiple Loop)
- Custom metabox value not saving
- Selecting which pages to display custom post type on using checkbox
- Delete attachment with post
- Get link for feed of specific post type AND taxonomy
- Cannot modify a registered custom post type rewrite slug
- Display all post types together
- Get data from custom post type to another custom post type?
- Using get_terms() as shortcode attribute
- Displaying information from Custom Fields in template with Types?
- Change column of row action (Quick Edit) links in WP_List_Table
- Collection of fields in a single post
- Add Excerpt On Quicksand Plugin
- Custom post type adding additional markup
- Turn post into simple slideshow
- Problems with a custom meta_box
- Make title field multiline in the add new custom post page?
- Select Menu for Custom post Type does not save
- Multiple Block Quotes without using HTML
- 2 language CPT content
- Allow certain part of a page to be easily updated for client?
- Is There A Way To Add Another Field To Custom Post Type (Not Custom Field/Meta)?
- What’s the best way to show custom post types? With page template it’s not perfect!
- How to apply order on custom taxonomy and custom meta key on custom post type
- How can i display on front page a movie that is atached in a post type
- How can I make a custom post type that loops pages in a new dashboard page, each single page is a new dashboard page (all within the back-end)?
- Data won’t save on a straightforward metabox, what am I missing?
- empty dashboard for custom role
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Custom post type – columns order
- custom post-type query just returns two posts
- Custom post type functions.php if statement on action
- Add Image field to CPT
- Query multiple post of which one by taxonomy