Thanks to @WebElaine’s comment. I needed to move the template return outside of the function so that it looks like this:
public function add_my_template($template){
if ( is_page( 'my-unique-page' ) ) {
$template = plugin_dir_path( __FILE__ ) . 'page-my-unique-page.php' ;
}
return $template;
}
Related Posts:
- Autogenerate wordpress shortcodes using array?
- Shortcode display outside the div
- How to remove action from plugin?
- How to stop or remove an action being called inside a function of an extended class
- wordpress plugin is not activating from widget
- Calling plugin function inside custom plugin for onclick event
- Facebook Messager Plugin
- What is @Action in WordPress?
- Create a post builder skin in a plugin
- Plugin Development – Functions or Hooks?
- Are there action hooks for comments?
- How to remove a class function from a plugin by using remove_action()?
- Add action to custom Function
- the_posts_pagination() not working if I add wp_head() to header.php
- The function called on the wp head hook becomes null
- Sharing varible between two add_actions
- How to Unhook actions/filters in within Class in plugin
- WPML – Hook when language is switched (change user language)
- Call function with button and return response
- Use action, filter, or hook to append HTML to WordPress plugin function
- How to echo a plugin’s function into a template?
- how to repeat taxonomy in different places on wordpress
- AJAX login without a plugin does not work. when add a action to function.php
- add query string to all pages after user logged in
- Call a function with href
- Re-use date format on different template
- How can I edit post data before it is saved?
- Manually set global $post vars with an ID, in order to use template tags
- How to not allow users to create new tags, but allow to them to use existing ones
- Is it possible to stop selected plugins from loading on certain template pages?
- Limit access to posts/pages by user roles
- Common functionality between my own plugins
- Editor access to plugin settings
- Saving Plugin settings to the database
- Get image URL from media library in input
- Can wp_script_is used in pluginA check if a script is being enqueued/registered from pluginB?
- What is the purpose of $merged_filters?
- add action wp_head not working
- Where to place custom functions?
- AJAX button run function
- Get posts from WP_Query and format them on admin_head
- Display post lists in 2nd paragraph
- How to display custom sidebar in wordpress 5.5.2
- creating html reusable blocks via shortcodes
- Replacing a plugin function with a custom renamed function doesn’t work
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- Add comments for template variables
- How to create an option page for this simple plugin
- the_tags : can we insert a class
- _prime_post_caches in wordpress
- Best practice for including plugin output in a template without using shortcode?
- a weird attribute on every html tag
- Submit Form data to another page via Ajax (WordPress Way)
- WordPress checkbox and Illegal string offset
- Why do plugins often ask to add in to templates?
- How to get menu location in wp_update_nav_menu hook
- Undefined index: action plugin problem
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Adding class to last list item? Not WP generated
- Default taxonomy template in plugin, override in theme
- I changed .live() to .on() but change is not reflected on the server
- wp_enqueue_scripts
- Advanced WordPress plugin activation detection
- how to execute some code after a post is published in WordPress [duplicate]
- Pagination shows Same posts
- Changing plugin options from theme functions file?
- Expected ‘add_filter’ (T_STRING)
- How to hook into action/filter call
- My widget won’t update its values when save is clicked
- Adding a pagenavi to function for displaying bookmarks
- What is the most efficient way of adding additional functionaliy for admin only
- Error Metabox Warning: call_user_func() expects parameter 1 to be a valid callback
- Replace the_content with ACF Flexible Content via function
- Create category for each user
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- Cannot pass value variable to WP AJAX functions
- How to add post title to custom php?
- Easiest way to load/fire a handful of functions, IF checkbox is checked?
- post id or permalink auto-incrementing number and reset everyday
- Programmatically generate new pages for a site based on page template and content elements accessed via DB
- How to change the deafult template in WordPress plugin
- Get a Taxonomy values in an array
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- Why isn’t my plugin seeing other classes?
- How to add submenu to WordPress plugin in the same Directory of main Plugin?
- Contact Form 7: custom validation [closed]
- functions.php conditional output for a single plugin
- OOP Plugin: Where should I place the action hooks in the class?
- Single dash converted to double dash
- How to declare this function correctly?
- WordPress show different custom post type
- Can’t modify plugin function
- Make plugin admin page visible to other roles
- wp_enqueue_script doesn’t load JS in plugin
- How to provide page_template path in custom plugin using WordPress
- Read page- or post-content across different builder-plugins
- Remove posts that start with similar words (like a delete duplicate posts plugin)
- Add custom button to the changeset status in the Customizer
- How to get next day date of a specific day