I noticed that your goal is to have an editable content on the search result. You can use another method to do that, by calling the content of the page from your search.php
file.
You can start by creating a page with the slug search-page
as usual. You can also add post meta / custom fields as you need.
And now you can start editing the search.php
. Inside the search.php
get the page content by using
$page = get_posts(
array(
'name' => 'search-page',
'post_type' => 'page'
)
);
Then use the page data inside the $page
object in your template. If you need the page meta (custom fields), just use the get_post_meta()
functions.
Related Posts:
- Restrict a search to a custom post type
- Modifying searchform.php and search.php to have two kinds of searches
- Unable to create custom search results template page
- get_search_link() redirects to 404 template page
- Search results when none found – stay on page they were on
- Redirect template based on permalink rather than $wp_query
- Standard WordPress Search does not work / Search-results are not displayed / Custom template
- How to identify which template WordPress’s default search-form retrieves in my theme
- How do I override the search template in a plugin?
- Conditional to determine if search.php page is the current template
- How to use another file instead of home.php
- How to name custom search page PHP file?
- Search button click sends to single-custom_post_type instead staying at the same page
- how to change custom post type search template to output search results in posttype-archive.php
- Where is search.php?
- Is it possible to return a specific tag archive/template as one of the search results?
- Search results in custom template
- How to change the default registration email ? (plugin and/or non-plugin)
- How can i change email template for new user
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- Prevent comments_template() to load comments.php
- Page editor missing Templates drop down
- Custom templates folder
- How to Rename a Template File?
- get page templates
- Load entire NextGEN gallery from single thumbnail?
- stop blog page from using index.php?
- How to customize search result page title?
- How to assign a class to a page with a custom template?
- Proper Javascript Implementation
- Guest author’s post not display in author template
- How to apply a custom template for posts by default?
- How to Increment ID value within ACF Repeater Field Loop
- Is there a way to check which template file is being loaded, if it is not a page template file?
- How to remove wp_link_pages() from template
- How can I get WP to use templates in lower-level subfolder?
- how to make a home page for wordpress custom theme
- Generate Catalog Of Posts Based On Template
- Extending body classes in front- and backend
- How to get the most recent modified date of anything in the footer of my site?
- How do I find the directory of a page template?
- Is there a way to set different post templates for parent posts and child posts in the same post type?
- Why write markup for index.php?
- Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations
- How can I hardcode template selection?
- Changing layout programmatically
- How to use same page template if post status other than ‘publish’?
- Possible to have one template call different sidebars for different pages?
- Is there any way to write custom HTML is some .php file and then call it wherever necessary?
- How to redirect my custom template page to content-none.php if no posts found?
- Get URL of current post but not the page number
- Is template name always same as directory name?
- Single Post Breadcrumb not linking back to Custom Post Type Index?
- Form post to WordPress page = wrong template
- How can I add text to a specific ‘Edit Page’?
- get_month_link uses what wordpress template?
- Load custom script on a single template
- Archive template limiting to 4 entries?
- Author template help. How to check if field exists in the profile?
- Can you use block patterns in block templates or insert them programmatically?
- WP redirect to custom login page if a user is not logged in
- Differentiation between index.php and page.php
- Change default template in the block editor (Gutenberg)
- How do I create post template for different taxonomy
- Ip2location plugin in my template header?
- Import a header template from another theme
- How are the HTML classes generated?
- Page Template with Sidebar Naming Convention?
- Adding text to the footer of each post based on tags or categories
- Blog page won’t show Blog template
- How can I abstract code out of a template by using functions.php
- Make Permalink go to specific template
- WordPress function.php on ZendFramework CMS
- Site Title appearing twice on live site
- Give user option to select full post index page or excerpted index?
- the_post() in RSS feed
- how to change already posted blog to custom template wordpress?
- WordPress change title with custom dynamic
- template with multiple post loops for multiple widgets [duplicate]
- Random home page at each refresh between array of page IDs
- Do not trigger page 404 on custom template
- Print different parts of content in template
- How can I pass a variable from a template to header.php of a theme
- Page Template Selector Error
- Change Page Template Based on URL Rewrite in WordPress
- I want to display all related posts for a selected tag in WordPress
- How can I modify this code to include the parent?
- WordPress Child Theme Template auth_redirect wrapper
- Show a custom template, no matter the page being viewed, if the user is not logged in
- Is this the best way to complete disable category archive pages?
- printf, translation and the_author_posts_link()
- Tag Posts showing in wrong places
- Problem with custom page template and permalink
- front page won’t change templates
- Including 2 Negative Is_Template Conditionals in header.php [closed]
- Add custom card template to masonry layout using Essential Grid [closed]
- Where is the general html template file?
- templates page not showing on gutenberg editor
- How to load php templates from html page (block theme)