You can use the is_page()
function or is_single()
function to echo content to front end pages
function add_content_to_page {
if ( is_page() ) {
echo '<p>content</p>';
}
}
or combine the two :
function add_content_to_page {
if ( is_page() || is_single() ) {
echo '<p>content</p>';
}
}
Similarly you can do is_page(41)
to target a specific page id
or is_home() || is_front_page()
to target the homepage alone
there a lot more options and examples in the WordPress codex
Related Posts:
- How can I configure Docker for developing and deploying a custom theme?
- Add screen options to custom admin pages
- Add self-closing shortcode button to TinyMCE in WP 4.6
- Completely remove WP_Admin_Bar for specific user roles
- WordPress and PHP Sessions – Security and Performance
- WordPress Hook for user register
- What is the difference between using global $current_screen and get_current_screen()?
- How to make repeated component/block in Gutenberg
- Must-use plugins autoloader: How to use get_plugins() correctly?
- Changing upload directory for plugin uploads only
- Upload file to remote storage
- How do I conditionally enqueue script for CPT single post type with plugin?
- wp_localize_script $handle
- Help adding image upload functionality to widget
- Why won’t register_setting() create a setting?
- One time username change from frontend?
- Customizer Not Saving Options
- How to extend a plugin like we do a theme?
- How to add custom text in wordpress logs
- Rewrite url for existing page without flush_rewrite_rules
- Front-End Interfaces Without Shortcodes
- Is there a way to loop through a shortcode datasource to create a table?
- Execute plugin for specific user role(s) only
- WordPress REST API, run long background job
- Make a list with header and subtext in Gutenberg blocks
- Get the post id as early as possible
- Custom plugin changes not showing
- How plugins_loaded works?
- Enqueue scripts in footer
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- the_editor() function
- How To Prevent Certain Folder To Be Overwritten During Plugin Update?
- Including the necessary functions for a custom ajax registration form
- Why doesn’t my simple the_title filter get applied?
- WordPress clean internationalization for menus?
- JSX in WordPress Plugin Development
- W3 Total Cache JS and css Minify folder are empty
- Including third party libraries in plugin [closed]
- Force HTTPS 301 redirect with hook
- wordpress JSONAPI introspector always limits number at 10?
- TinyMCE editor turns white on Biographical info [closed]
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How I can use order by of the custom post title?
- WordPress Specified file failed upload test
- Custom Post Type to override theme’s CSS & HTML from Plugins Dir?
- How to create custom settings page for custom plugin
- Move some files of plugin to the root directory with plugin activation
- Internationalizing Plugin
- Update File Once Every 30 Days
- Taxonomies within plugin invalid
- Make Database query only when option is updated
- enabling Twig as Template Engine withing own plugin [closed]
- Unable to get a simple plugin admin page to work
- Use npm and wp-env to make production bundle
- Looking for a better way to initiate cron job
- shortcode executed in the page editor
- Set _regular_price 0 if empty in woocommerce product
- How do I get rid of my inclusion race-condition on wp_enqueue_script
- Form using admin-post.php gives 404 after submission
- per blog metadata for plugin
- AJAX call to admin-ajax.php by subscriber returns home page
- How to use gettext for specific user role
- Custom Post Type Object – Undefined Variables
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Ajax function is not working on WordPress
- Best way to ping for the API changes in the wordpress?
- Create an user on external database
- Form submission to another page returning 404 error [duplicate]
- How does “Your comment is awaiting moderation” work?
- How do i remove the title from a specific page
- Widget internal hooks and functions
- WordPress plugin advice: suggestions for writing a plugin the correct way
- How to link to custom “archive like” page with custom permalink rules “dynamically”
- rewrite_rules problem
- check_admin_referer()
- Creating an ics calendar from custom post type
- Catch metabox values in Plugin
- Dynamic page generation upon purchase of a product
- How to show the posts listing on dashboard or custom page in admin panel?
- Settings API not saving
- Allowing duplicating users with same user_login and user_email
- Updating the_post content is only working with Twenty Twenty theme
- Scripts/styles not loading on cloned WP Site when logged in
- Save in my custom admin page and redirect to the saved object
- WordPress delete mysql rows with string
- WordPress Plugin: OSCommerce images not displaying in front end
- How put the correct URL to sub-menu plugin?
- WordPress-child problem with many css files in parent theme
- Can a standalone app be made to work as a WordPress plugin?
- Script work on non logged in user but not work for logged in user?
- admin page passing $_POST variables to itself
- Create and style menu
- Get URL of Post You Are Editing
- Nothing happens on WordPress Update command
- Plugin – Proper way to handle 404 pages?
- Is wordpress plugin development active? [closed]
- get the queried_object of an url
- Advanced Custom Fields conflicting with custom plugin when saving custom field
- plugabble wp_authenticate function not works from wp-login.php
- How to get recent one post from each category on home page?