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
- Programmatically set page template based on page ID
- Query children and parent title
- Help to resolve Syntax error, unexpected ‘endwhile’ (T_ENDWHILE) [closed]
- 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
- 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?
- 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
- 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?
- 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
- 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
- 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 do I register a new settings page? [closed]
- 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?
- 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
- Retrieve a custom form field modified by a filter
- us states dropdown function and echo in theme template files
- How to pass a variable from a template page to the child theme functions.php
- Define an extra field for all pages (with no plugin?)
- Custom field not updating via functions upon publishing
- Function the_content
- Allow the access over wp-login.php
- Shortcode to output get_header not working
- Using array page name together with page id to deregister script
- How to add a class name to the ancestor of a post?
- How to add an excerpt and read more link to a page?
- How can i hide content if not friend in Buddypress? [closed]
- Which template file to edit to edit homepage in Mystile [closed]
- Make a PHP file with a function
- Creating mixture of shortcodes to use in the visual/text editor
- How to store page-{id}.php templates in custom folder