It’s one way to do it.
I like it, because it allows you to write HTML code pretty easily and it makes it pretty obvious and easy to maintain. But it’s just opinion based, I guess.
It doesn’t harm your performance to much. You shouldn’t use output buffering to generate whole content of the site, because you want to start sending response to the browser as soon as possible, but this is not the case here…
You can also:
- prepare the HTML output by concatenating strings (it’s harder to read and easier to make some html errors, IMHO),
- use some “view” pattern
Related Posts:
- Software for WordPress Theme and Plugin Development? [closed]
- How to detect mobile devices and present them a specific theme?
- How to override pluggable function in theme?
- Should we use get_template_part() in functions files instead of include_once?
- Reset positions of metaboxes in admin
- Remove the word ‘Categories’ from wp_list_categories
- Using Bootstrap in themes
- Add a dropdown to theme customizer
- design and development workflow
- How to control initial wp_head() output?
- enqueue script for specific shortcode
- The difference between calling wp_enqueue_scripts to load scripts and styles in custom theme
- Any walker causes blank menu?
- How can I insert default widgets when my theme is activated (similar to what twenty eleven does)?
- How to change post thumbnail title and alt attributes to post title?
- Why might $input (Settings API) be coming through empty?
- add generated stylesheet from parent theme after child-themes style.css
- date_i18n() issue
- Creating Page Based on Category
- How to check if post has any tag?
- using wp_enqueue_script to attach jquery-ui
- Merging PHP download script into `functions.php`
- Should use widgets in this case?
- Changing the entire control choices using wp.customize with JavaScript
- Static Front Page problem
- Can not Remove Archives and Meta from Sidebar
- Get last modified date for menu link
- How to add multiple custom widget areas
- A theme that follows all the best practices to learn from?
- get_post() function returns post even if it is trashed
- WordPress how to override function adjacent_posts_rel_link_wp_head() in link-template.php the correct way
- Can wordpress run in root of existing php site with no theme on index.php but all other WP posts/pages?
- How to regenerate thumbnails when they’re stored on S3
- Change file name from wp_generate_attachment_metadata
- Change setting name in Customizer and keep the data
- CSS won’t style output of wp_nav_menu() correctly
- Creating multiple hooks for theme
- after_setup_theme, Global Variable and Theme Customizer
- How to make WP admin recognize a newly created child theme?
- Can’t show custom post thumbnail sizes as background images
- Single Page theme [closed]
- How to create a custom template to admin dashboard
- Change The Meta-Description Of Home-Page?
- filter “inactive” categories from wp_list_categories?
- Easy lightbox effect inside of dashboard widget
- Add, edit specific CPT with custom role
- how to display search term in the template full site editor
- Custom Field created in add_meta_boxes reappearing itself again in the default Custom Metabox
- Dynamically generated wordpress customizer options?
- Filter categories used with Custom Structure Permalink
- Code to determine WP version check
- cannot echo the_post_thumbnails
- How to escape html generate by a loop
- get_term_link is Ending to single.php
- making my theme multisite compatible?
- wp e-commerce – theme problem – why won’t it load wpsc-single_product.php? [closed]
- theme style is applied on the dhasboard rather than the website
- Moving post title down the page / Removing a block from a post
- I want to change background image of my wordpress site on particular post type
- how to retrieve the image title for image Post Format
- Iris color picker in custom theme option page not saving value
- Hestia Child theme creation
- CSS added through customizer neglects the need of a child theme?
- How to add custom class to get_avatar()
- Want to add cart and a search bar in the right of logo line
- Output richtext metabox value
- Twenty Twelve Author not displaying
- Read more doesnt work with query posts
- Default PHP document / names needed for a WordPress theme?
- Dynamic Image Links Depending on Excerpt/’Single Post’ View
- Custom fields for custom post types
- How can I sort my loop based on meta data, using a form?
- What is the_permalink() on a category page?
- How to modify theme content in Thematic?
- How to determine when my theme is deactivated?
- Sidebar not displaying (theme development)
- WordPress theme options checkbox default checked state
- Custom themes that won’t work when theme is changed
- only the first post is shown
- wordpress can’t find single-project page
- WordPress Theme: What is the right way to put inline CSS loading from a CSS file
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- Cold Fusion to WordPress
- How to show some of category in wordpress
- How do I build a WordPress Profile/Author Header?
- Make a custom field in admin post.php read only
- Create settings field on button click
- get_posts is duplicating
- Undefined index: custom_sidebars
- How To Customise WordPress Comment Submit Button?
- Single Featured Image Repeating
- How to remove menu from WP-Admin menu
- apply_filters to featured image
- How do I move menu to the bottom in Custom Community theme?
- How do I get information about a page, such as featured image, except, and title?
- How do I make it super customisable?
- Theme.json: creating different sections of the color palette
- .submenu class missing in output from wp_nav_menu
- Creating image grid on products page in wordpress
- What is the point of using archive.php instead of index.php?