Yes, please avoid closing PHP tags at the end of the file, not only with PHP 7, but with PHP 5 as well.
Reason is that if you close the tag, anything that is after the tag, even a blank line, will be sent to output and will make PHP to send headers as well preventing cookie to be set, redirect to work, feed to be valid, and so on.
I guess that you ever encountered a message like
Cannot modify header information – headers already sent by (output started at …) in … on line …
A closing ?> at end of the file can be the cause.
Related Posts:
- Why do templates contain so many PHP tag pairs?
- Displaying a WooCommerce product via PHP
- What exactly does “Posts page” do in WordPress?
- Check if a menu is empty?
- Get the php template file from other theme folder
- WordPress Template Engine?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- wp_remote_get returns an error for valid URL
- Blank on static home page?
- Adjust the results quantity for Search Results page pagination
- Exclude pages with certain template from wp_list_pages
- Categories Template Assistance
- Is it possible to use the featured image of a page as a css background without inlining?
- Unable to set right time in admin and frontend template
- Switching between custom templates in a post type of the admin menu
- Use template for posts with a particular category grandparent
- Placing the_content inside shortcode not working
- How to override wp-admin styling
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- An unwanted inline style is added to my body tag
- Automatically add custom CSS to new posts using a category template
- How can I load a PHP page without using a Template?
- how could I load a different template part by page
- creating a second image attachment template?
- Get and insert order email address to the PHP template inside HTML text
- How to show single category archive
- code is skipping a div
- Issues getting PHP to display in category pages
- Secondary navigation menu on one page
- Woocommerce Show Single Product on Homepage
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- how to show only specific category for a template
- Does wordpress templates always in files or in database?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Using same variable names in files added with get_template_part()
- Create a Blog Template Page
- Showing latest post without 301 redirect
- WordPress template page name displayed on screen
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- single.php with different look by category
- How to call multiple functions from multiple files into a WordPress page template [closed]
- How do I define a lookup table that will work across all PHP elements of the template?
- persist a variable set in header.php all the way down to footer.php
- Removing WordPress Footer -without access to PHP code?
- Why does the Woocommerce grouped template prints the unpublished products?
- Adding conditional text to a PHP Shortcode Template
- Create page template via functions.php?
- how to display this functions?
- is_page_template showing partial results
- Adding regular php file to site
- Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)
- add_filter function concatenate string and locate_template function
- Template Loop – add switch case php
- Post repeated when opening in overlay, how do I solve this? [closed]
- Need help with pagination
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- How do I query a single data value from the wp_metadata table?
- Splitting the_content() by size?
- Gravity Forms merge tags in templates?
- Unable to render custom field after attempt to generate a list of recent post in page template
- php loading different structure than source code
- pass html code to worpdress
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Getting a WordPress tag to print inside of a traditional php echo
- Loading Elementor templates in a Bootstrap modal on button clicking
- Require()/Include() post template adding extra content
- Display articles with a different template in the home page | Solved |
- Display metabox galleries on specific page template in admin editor
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- Run do_shortcode on php template using JS function
- How to hardcode header and footer in WP?
- What are the advantages/disadvantages of ways to use php template files?
- Change the “Show All” button in a WordPress Portfolio Filter
- Check if current post in loop is last on current page
- Converting Array to String Issue [closed]
- ACF – Custom image for Product Tags not displaying
- Roots Sage Symfony error when using override from template
- If is_page elseif is_page not working like I want it to
- How to display last whole post on the homepage
- missing admin bar and widget in a template
- What syntax is this? “{{post.price}}”
- My own theme’s custom widget areas are not working
- Add point on excerpt post
- WooCommerce – Print Processing orders [closed]
- Loop returns more items than exist?
- Access methods in plugin template
- Create dynamic content from one WP page to multiple other pages
- How to call a certain object/menubar in a PHP file
- why is this content-template not showing any of my blog-entries?
- how to register a second page-template
- PHP code rendered in HTML
- get_permalink returning first letter
- Custom Archive Page
- If I define a variable in header.php, how do I make it available to templates?
- php “use” not working in template [closed]
- Loop on a wordpress Page instead of content coming from the WP text editor
- Twig+WordPress how to use array arguments inside a function?
- How to edit templates created in the block editor in code / template files not updating