I think WordPress is one of the cases where the original code just got bigger and bigger without having a chance to be rewritten from ground up with best practices.
In this case, I think the WordPress conventional practice (writing markup in function) outweigh the best practices.
You might find the theme development documentation interesting to see the rules theme authors follow to develop themes:
http://codex.wordpress.org/Theme_Development
Related Posts:
- To close or not to close php
- What is the meaning of %s, %1$s etc.? [closed]
- How does printf( __( ) ); work?
- Return HTML Template Page with PHP Function
- Include WP_Query in my own PHP file?
- Why do templates contain so many PHP tag pairs?
- Is there a way to parse shortcodes in PHP?
- Displaying a WooCommerce product via PHP
- What exactly does “Posts page” do in WordPress?
- Check if a menu is empty?
- Static Frontpage Pagination – Custom loop
- Get the php template file from other theme folder
- WordPress Template Engine?
- Has anyone tried putting PHP ActiveRecord on WordPress?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- wp_remote_get returns an error for valid URL
- Copyright info change in Theme Child PHP
- On this day PHP code
- How to loop over custom fields in a page template?
- Blank on static home page?
- Add footer.php to WordPress child theme
- WordPress theme & site not loading after moving files
- I want to remove the links from the term list returned by get_the_term_list
- Adjust the results quantity for Search Results page pagination
- Exclude pages with certain template from wp_list_pages
- Use Timber/Twig to pull an image by image ID [closed]
- Categories Template Assistance
- Can I run custom php on specific pages in wordpress?
- Successful or Error Message after running mysql code in functions.php
- Is it possible to use the featured image of a page as a css background without inlining?
- Can I view my own wordpress php source code on my hosted web server?
- Unable to set right time in admin and frontend template
- Easiest way to show total number of subpages
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- How do i get (unique) page name?
- Blank space at beginning of tag?
- How to display posts of specific category using a custom Query in WordPress?
- Placing the_content inside shortcode not working
- Link to file in plugin directory from wordpress template?
- Password protecting content in custom template
- How to override wp-admin styling
- How to display php source code inside a post using visual editor?
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- The custom logo, site title, and description doesn’t appear at the same time
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- How to display user nickname (not display name) in PHP template?
- Custom Template 404 for specific custom post type
- An unwanted inline style is added to my body tag
- How to properly insert a link to a template in WordPress?
- Custom field value not saving when it contains a URL?
- stats_get_csv (WordPress Stats) to only display top posts (not pages)
- Automatically add custom CSS to new posts using a category template
- Hide wordpress field if data is empty in post!
- How to get the POST TITLE using the POST ID?
- Render ninja form inside markup
- How can I load a PHP page without using a Template?
- how could I load a different template part by page
- Latest post in a specific menu
- creating a second image attachment template?
- Mass update excerpt
- Cause of Blank Lines Being Added to WP FIles?
- How to save checkbox values for logged in users?
- How can I get a single php file that is the equivalent of an existing WordPress page?
- Add point on excerpt post
- WooCommerce – Print Processing orders [closed]
- Loop returns more items than exist?
- Access methods in plugin template
- how to run a php code in widget?
- Create dynamic content from one WP page to multiple other pages
- How to call a certain object/menubar in a PHP file
- how to add number value in front for variable [closed]
- Problems With Query and/or Template Part and/or PHP
- Blog only showing code
- Display pages from specific page template
- why is this content-template not showing any of my blog-entries?
- how to register a second page-template
- PHP code rendered in HTML
- Odd page behaviour after removing sidebar
- get_permalink returning first letter
- Themes with variable width or single columns? I want to display source code
- Custom Archive Page
- Open all external links in new window – need help with the code
- If I define a variable in header.php, how do I make it available to templates?
- How to refresh a template page on WordPress in 3 seconds – easiest method?
- php “use” not working in template [closed]
- How to get the Woocoomerce subtotal value without tax in the hardcode? [closed]
- Loop on a wordpress Page instead of content coming from the WP text editor
- Where to put include php file?
- Twig+WordPress how to use array arguments inside a function?
- How to implement a custom sliding banner? [closed]
- Can you not edit the HTML and PHP of your WordPress without paying?
- Dynamically added text at bottom of article – non searchable by PHP code
- How can one use variables in a template or template part without polluting the global scope?
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
- how to create twitter card without plugin in wordpress website?
- How to edit templates created in the block editor in code / template files not updating
- WordPress post-template null warnings
- AJAX Appending Data Adds Mystery “0” :(