instead of echoing a whole bunch of html you can close your php tags and just write html as normal.
for example:
<?php
...
...
...
foreach ($posts as $post) {
?>
<!-- here goes the html -->
<?php
}
?>
On the otherhand you mention in your question that you are trying to display html based on a page name.
You can do this by making a page template
Related Posts:
- How to find cause of PHP notices with no stack trace?
- The correct method to pass query vars in AJAX using ajaxurl
- Display user’s total comment count outside The Loop
- Getting the action’s tag name within the action
- WordPress Infinite Scroll without using any plugin
- Admin Bar (Toolbar) not showing on custom PHP file that loads WordPress
- How to add query vars with paginated URLs?
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- wordpress separate registration for different roles
- How to get user by display_name with WP_User_Query
- Changing Link Attributes for Wp_Link_Pages
- Problem with Woocommerce REST API Authentication
- How to get custom image size for image uploaded in Customizer
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- How to change
- Get only the grandchildren, not the direct children of page/current page?
- Passing POST data from one WP post to another
- Use wp_remote_get to get JSON instagram feed from public profile
- How to add SVG icon above product tab title
- WP_Query sort using multiple numeric meta values
- Call to undefined function issue
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- How can I generate random numbers inside my shortcodes on each implementation?
- custom widget on the footer
- How to create a custom category of wordpress admin
- WordPress automatically adding html tag around PHP code
- WordPress does not load page.php, return 404.php
- Converting HTML Template to WordPress Theme
- How to hide all child pages with post_query?
- PHP Warning: chmod(): Operation not permitted in class-wp-filesystem-direct.php on line 173
- Saving an array of dynamic repeater data as post_meta
- How can I apply_filters from inside a function?
- Image rotation and editing stopped working in WordPress after upgrading Ubuntu from 16.04 to 18.04
- WordPress asks you for your FTP details if you want to run Automatic Updates/Upgrade Plugins
- Populate editor with some content of a page with a page template
- I want to load in a new class but only if the current page is single-movies.php
- wp query foreach deleting record returning only first or last item
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Skt full width basic slideshow problem
- RTL Stylesheet Confusion with WordPress
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- get_template_part() not firing within a switch statement when template has new WP_Query
- How to show/hide php table rows based on the content of custom fields
- How to determine from a different folder (outside wordpress) if a visitor is logged into WordPress
- Is a series of update_option calls safe, performance wise?
- get comment data using comment id
- how to get serialized post meta
- Scheduling an event inside plugin class is not working
- How to catch wordpress post ID when it’s published
- WP check_ajax_referer() is not working
- How to access or parse key/values that have “string”
- Will I have problem with PHP 5.5 and WordPress 4.9.4?
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- Trying to run website a php file is blank
- Class property seems to lose scope, attached to save_post action?
- exclude custom post type from running a function
- Create condition for Author bio Social Links
- WordPress – Get Posts with Category data
- Change Language Title Pagination on Subdomain non Multisite
- Call to “admin_notices” hook from a static method
- How to Create custom block for displaying information in content section which act like shortcode
- How to use Page link field with is_page()
- wp_query – Exclude the first thumbnail from lazy loading on archives
- Running SMTP Conditionally
- How can I pass php code as a content while publishing a post
- Change lost password url to a mailto URL in WordPress
- Usermeta data unserialize, extract and display in table in WordPress
- Trying to show the category of a post in the post display
- Displaying SQL query result from user input via wpdb
- Display specific page if user signed in
- 500 Error, Get custom field and returning it
- How do I add this OnClick event script to a custom button I’ve created?
- How can i limit the number of posts to the most recent 6 in my query?
- wordpress dependent dropdownlist using post type is not working
- Post content, PHP help
- How to insert text into post based on category – via single.php file
- Access certain Entry in HTML-Table and pass the entry-data in WP not working [closed]
- is_user_logged_in() not working in homepage
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- I want url from a file in media using title file
- how to get buddy press messages based on thready_id?
- Widget Logic – display on page and all child
- How to associate dynamic PHP page for chosen WordPress tag?
- Child theme functions.php file change database entries
- Get dimensions of logo
- How to call javascript function (jquery) in a shortcode?
- Add custom filter to register data in array
- Rename Index.php
- Why does WP_Query show only the same post even with different categories and endwhile?
- Run A Pre-Built Core PHP Application Under A WordPress Page or Post Route
- show/hide attachments
- How to display different widgets on specific pages, hide from other pages
- Troubleshooting “loopback requests that take too long”
- AJAX & PHP | Call a specific PHP function from a PHP file via AJAX?
- Order woo products, but first products must be with acf fields
- Remove /category/ from category (archive) page URLs (without using a plugin)
- JSON Object Value Show Undefine
- Correct way to perform a GET to another PHP file hosted on wordpress