You can get the name from the global $template
. I don’t know of a way to get it with an API call instead of a global, but such is life.
function floridacontent( $content ){
global $template;
$name = basename( $template, '.php' );
if( 'page-florida' == $name ){
$content .= 'Forida added content';
}
return $content;
}
add_filter( 'the_content', 'floridacontent' );
Related Posts:
- Define custom Page Template without its own .php file
- Filter the query ONLY for the search results page
- remove empty paragraphs from the_content?
- Issues with title-tag and document_title_parts
- Remove Actions/Filters added via Anonymous Functions
- Set JPEG compression for specific custom image sizes
- Define page template in wp_insert_post
- Add custom template page programmatically
- Add class to menu items of one specific menu (nav_menu_css_class)
- How to influence the information displayed on widget inside wp-admin
- Removing default image size list in Media Box
- How to restrict actions and filters “properly” by conditions
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Using add_filter() in Widgets
- Customize WordPress Media Manager – Media Window
- How to reduce original image quality on upload?
- Is it possible to use a forgot password url filter?
- syntax for remove_filter in parent theme with class
- Add body class of category parent
- Wrap gutenberg block ‘div’ in other elements/extra HTML
- Convert hyphen to underscore in permalinks
- Override parent theme function that is not hooked or in the functions.php file
- Remove Page Title from Static Frontpage
- Programmatically Add Font-Awesome Icons to Category Widget
- Remove bulk actions based on user role or capabilities
- Default or Preset Content for Custom Post Types
- Custom page template how to check is_page from functions.php?
- Override a class function to include a custom template
- How to override filter in child theme?
- Removing title from page
- Hide some items from Screen options in dashboard for products
- How to change a certain text or term of WordPress into a custom into the whole site?
- Run Product Filter Javascript On Page Template
- Adding body class when post contains a specific shortcode
- Replace Archive Widget Link Text
- Programmatically set page template based on page ID
- Exclude Empty Child Categories in Menu
- Adjust which tempalte a page uses with a function?
- Best way to programatically add “rel” attributes to page and post images
- add_filter priority problem
- Limit filter upgrader_post_install to a single plugin
- How to update feed only 2-3 times a week (for Feedburner email)?
- Manipulate Output of wp_list_something: select menu instead of li’s
- Clean-up script tags
- How to specify which Gutenberg blocks are available in the editor for a page template
- How to use IF Statement in WordPress?
- how to change link of some wordpress pages
- Gravity Forms field entries into wp_query loop [closed]
- Post Pagination Showing Same Posts Every Page
- Show excerpt for only first post in query
- Remove function or filter
- Filtering posts by category name based on page’s slug
- modify a function filter
- Super simple shortcode not working
- How would go about if I just want a temporary function?
- Generating rel=prev and rel=next only on wordpress categories
- How to make applyFilters function return false via functions.php
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Accepted arguments value in hook functions
- Get current page_id before loop, in functions.php
- Which action hook to use for function?
- Adding multiple taxonomy filters to functions.php
- str_replace function in theme
- is_account_page() change to page slug
- How to enable template page only for a post id page
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Adding HTML to the end of every post with the Block Editor
- Last updated date function
- Activate small php condition at footer over page template
- Modify a function without editing template
- How to set default archive image without overriding first attached image? [closed]
- How do I add Bootstrap and LESS to my migrated WordPress site?
- How to add nav menu items to a specific position within a menu
- Get_template_part inside a folder
- Passing values from a widget to a function within a plugin
- Only let plugin add actions to wp_head & wp_footer on single posts
- Publish/Update post is changing image links from file url to post url
- Disable auto-resizing of uploaded images, but only for certain filename
- How to make custom column Admin>Users sortable?
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- Get Current Post ID in functions php, meta query filter
- Output and filter data from a XML url
- Add to cart php not working [closed]
- Is possible add icon in title posts only in specific tag?
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- create filter in functions.php
- How to filter $content in shortcode function
- Insert image in WordPress with HTML5 tag and caption function
- How to construct function for applying filter?
- Adding an external HTML link to a post thumbnail
- Replace a menu with widget or a custom template file programmatically
- woocommerce change currency per category [closed]
- Run wp_kses_decode_entities on atom feed?
- Filtering out the #more anchor link that gets produced by
- Can’t filter wp_get_attachment_link
- append to existing parent theme function
- Pass parameter to hooked function using custom page template
- different style sheet for just one page template
- Add Element as a Filter to the_content
- Override the WordPress core function wp_referer_field