The template tags (like the_content()
) aren’t available when using get_posts
. In order to make the template tags available, you have to make use of setup_postdata( $post );
Example:
<?php
$posts = get_posts('category_name=category-test');
foreach($posts as $post) {
setup_postdata( $post );
the_title(); ?>
<p><?php the_content(); ?></p>
<?php } ?>
Related Posts:
- My custom template page not loading content inside it?
- How to detect if some page template has been selected
- Conditional tag to check if ‘page.php’ is being used?
- WordPress page edit does not save selected template
- Set page template automatically based on parent
- Is there a default template file for child pages / subpages?
- How to display code if it is not certain pages?
- Change admin startpage to Pages-page?
- Multiple areas of dynamic content in a page
- How do I set and list page_template with wpcli?
- How do I modify this page template to show subpage excerpts (not post excerpts)?
- Limit number of pages that use a specific template?
- How to inject custom url path for page ?
- Dynamically Load Styles and Scripts from Theme Functions.php
- Add custom admin menu item for pages using a certain template
- Is it possible to set a page template on a dynamic home page (articles list)?
- Different “Text Widgets” in Sidebar on Many Different Pages?
- What’s the most minimal way in which a page can be hooked into WP?
- Can’t change parent page
- How do I create multiple page while active a theme
- How to make certain page templates visible to admin only
- How to dynamically save a selected option from page “Templates” selectbox?
- Redirect “Sorry, you are not allowed to access this page.” to Home
- Custom /page/2/ template (different from index.php)
- Is it possible to have a landing page based on the visitors location?
- How to add meta boxes to Pages
- Custom page template not working
- Dynamically change page that loads
- How do I pass data from page content to the underlying PHP template
- How to change only the home page / front page url on wordpress
- Password Protected Page Title
- is_home() returns TRUE on page template
- Determine page content based on page parent
- Displaying page content in category archive (archive.php)
- Missing ‘Page Attributes’ in page edit
- Site url is not showing the home page
- Could be a namespace conflict (?) with login form and register form on the same page
- Updated WordPress, now getting errors on site
- Custom page template for multiple pages
- Get parent of current page
- How to edit a HTML list in WordPress?
- Custom page with queries returns 404
- How to capture GET argument on static page
- Add a static page that links to homepage
- the_content of template page
- Remove comment section from new page
- WordPress theme: Add page content to the bottom of the Contact form
- Create page template with some static contents
- Can I change the “Home” text in the menu?
- WordPress 3.2 – removed ability to select a page template in the page attributes when adding a new page?
- Parent page shows no child content
- Use same page-mypage.php template for several pages
- Avoid pages losing template association on site re-deploy
- How do you implement a page template automatically being applied to a page?
- How to create different template designs for different pages in WordPress [closed]
- Different css file not working for the page template I created
- require_once not working
- Page templates in subdirectories and auto generator
- WordPress Page doesn’t load the template selected
- Use page template for custom $_GET content
- creating single page with 2 columns while theme is 3 column
- How to bypass 404 for certain pages/posts?
- Outputting content from page
- Custom folder for wordpress page templates
- Authors posts on a author created page
- Static Website No Titles But Still Nav
- page template – undefined structure in source code
- Limit the amount of main pages
- On the list of Pages, clicking to Edit a particular page redirects to the list of trash
- My pages are using my Index.php and not my page.php
- WordPress custom pages in a folder
- Different template parts when on different pages
- Create page template
- URL redirect to home page issue in word press site
- How to change default home link title?
- Static Home Page resets to Front Page
- Why my home page doesnt work?
- WordPress blog posts template bug [closed]
- WordPress form submit to custom page template does not work
- Using external DB within wordpress
- What’s the best way to manage sections on a page?
- WordPress Page All Content In Template Good Or Bad Convention?
- How do you assign custom template for Posts page (under Front page displays setting)
- Content template when adding a new page
- custom page or standalone page?
- How to display time when page is created and edited
- Call a function on every wordpress pages only
- Specify parent page template
- WP Template Hierarchy – Need help choosing the correct templates
- Custom Filter using meta_value in wordpress admin list not working
- how bbPress and buddypress add their own page templates to the page template drop down on the page editing screen
- Showing certain page without redirection
- Create a new page for each form selection
- pagination does not work with query_posts. Help! [duplicate]
- link a custom page into menu
- exclude page element from specific pages
- How to display text of a page in home or custom page?
- How do I create a page that displays the homepage?
- For some reason my posts are not showing up on my front page [closed]
- May I know where to edit the tax rate?