It sounds like get_template_part()
would do the trick.
In element.php
you could simply call get_template_part( 'element-item' );
, which would then include the element-item.php
file from your theme.
You could wrap this up in a function if you wanted to, e.g. get_element()
.
function get_element() {
get_template_part( 'element-item' );
}
This approach would allow you to add logic into the get_element()
function so that it only gets the template part under certain conditions and it would keep the element.php
template from our example cleaner since the logic would be bundled up in get_element()
.
Related Posts:
- How to include local menu based on page id?
- My website is generating weired url parameters of paginated pages
- Why isn’t is_page working when I put it in the functions.php file?
- Get the ID of the page a menu item links to?
- How to redirect to post if search results only returns one post
- How to override admin-bar style
- Disable visual editor on one specific page
- How can I programmatically create “child” pages on theme activation?
- wp_get_attachment_image returns different image size
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- How to customize search result page title?
- How to display error messages using WP_Error class?
- Slugs as breadcrumbs for Pages
- Check if has any sidebar active on current page
- How to fix a theme with page.php Default Template that accidentally deleted?
- Remove Page Title from Static Frontpage
- WordPress Change Post Templates,but not drop down, but Image selection
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Using locate-template & shortcodes doesn’t appear to work
- Can I use require() function in a template file?
- How to set global variables in template page?
- Why isn’t is_page_template() adding a body class?
- Pages should have priority when using add_rewrite_rule
- Enqueuing Script in functions.php vs on the page
- Dequeue script in template isn’t working
- Programmatically set page template based on page ID
- Query children and parent title
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- Adjust which tempalte a page uses with a function?
- How to change menu icon which is overriden (i.e. by WooCommerce) [closed]
- Delete pages and Create default pages for all new network sites
- Make “sidebar template” the default template for new pages
- how to change link of some wordpress pages
- Make menu structure match page heirarchy on page parent change
- Retrieve post modified date for specific post by post ID
- Change the slug of a particular page every x hours
- Attach parent category template to all subcategories
- wp_insert_posts keeps adding multiple pages
- Add class or ID to any WordPress function
- How to remove howdy dropdown menu content
- Batch update menu_order attribute alphabetically
- How to create function from code?
- Display Password Protected external RSS in wordpress template
- How to extract the variables out from “add_shortcode” function?
- Default Gallery Edit/Template Editable?
- is_account_page() change to page slug
- How to enable template page only for a post id page
- Selective Product Category for Carousel
- How to change login labels
- Modify a function without editing template
- Retrieve tags data in post body
- Don’t delete a page if it holds users
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- Display post shortcode content in the sidebar?
- Why is my page feed returning empty content?
- Function only on a specific page
- Full page template function
- Get page id or status by private pages?
- Use WordPress function in php file
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- I have problems with loading javascripts
- Pass variable from action back to template
- Need print logo without any ID & class
- Define PHP variable from a seperate API if statement
- Enqueue script on every page except one
- Best way to handle lack of titles in microblogging
- attachment page template? only show attachments for current post?
- Run a jquery script on on a certain template page
- How to include any template using Shortcode fuction?
- Image loading function not working on archive.php template
- Add a field into a shortcode of an extension
- Specify multiple categories for custom post template – FATAL ERROR
- Using functions.php to include code that’s processed inline
- How to make a new function that includes a template
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- How do I register a new settings page? [closed]
- Only echo Page Content (not page title & page content together)
- get content from page through AJAX
- Show admin page, only if function is being used
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Prevent creating multiple image resizes in twentytwelve template
- Simplest Way to Build Custom Archives Page?
- Display ACF category image on archive and single template files
- How to assign php file(template) to several pages with same prefix page name/slug
- Render page with specific id from functions.php
- How to require a config file in a template and in function.php?
- the_date() and the_time() functions display actual date an time instead of published date and time
- Load templates, pass arguments, and render output from functions.php
- Changing the HTML of notices in WooCommerce [closed]
- WP Enqueue Script Error
- Remove the delete link from pages without a plugin
- More than one search results page template for two searches on site
- WordPress function with attribute pass to template
- Change is_front_page() to is_page() to display ‘hero’ on entire site?
- Javascript and Stylesheet in child page
- Newest comments first not working