There aren’t any errors in your code. I’m able to copy / paste it into functions.php and return 3 posts categorized under “testimonials” without issue.
By default this WP_Query will retrieve only ‘post’ matches so if you are using pages or a custom post type you’ll need to specify that in your query args as:
$args['post_type'] = 'page';
or
$args['post_type'] = 'custom_post_type_name';
The only other thing to check is to ensure you’ve added posts to the “testimonials” category in the WordPress dashboard.
I hope this helps.
Related Posts:
- ZIP up all images displayed in a [gallery] and offer as download link
- How to use “Add link” pop up for a WordPress widget
- the_author() returns empty string
- How to get all posts related to particular category name?
- Custom permalink structure only for default posts
- Add a new post status in the post progression
- How to add a quicklink to the Posts Admin Published|Scheduled|Trash menu
- Getting the Next and Previous Posts Titles in the Sidebar?
- Email admin when post pending?
- How to control which category will be picked for the slug of a post?
- How to hide the Text Area in the Post Edit screen
- upload image in a meta box
- WordPress Number of Posts Not Changing With posts_per_page
- Search posts by post author name
- Why is our post editor stuck at cols=40?
- Adding a Nav menu to post admin
- Comments enabled, but disabled at the same time
- Mass Update lines of code for all posts
- Adding Multiple Values to a Post Meta Key
- How to get a nofication when post submitted
- How to link up “read more” on excerpts hack from WP Recipies
- Any idea why wp_insert_post is succeeding but not returning?
- get custom image size
- Does an article (post) id ever change?
- Check is_single() outside loop
- Only display a certain number of posts, dependent on how many posts there are available in a query
- how to replace embedded “full” sized images within a post with the “large” ones
- Get Posts via Taxonomy Term Name with Space
- Change default Posts page
- Create post for every user?
- Facebook Share Thumbnail
- Auto “expire” all of an authors posts on spcific date
- How to pass Post_ID variable from theme’s Single.php to custom Plugin using AJAX
- Yearly archive page for future year
- How blog page in WordPress works : blog page retrieve first post ID
- Delete WordPress posts from URL list sql query
- wp_insert_posts add title with count of posts plus one
- Adding specific post category between posts in loop
- Relative redirects for posts, categories, products and product categories
- Default to ‘all’ view on the ‘edit-post’ screen for authors
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- WP Admin register taxonomy and post type performance
- How to get the last selected media alignment setting?
- Send post id through ajax and get the post content back
- How to make multiple sections in home pulling posts category wise?
- Permalink doesn’t get displayed in Twitter button (Local WordPress problem?)
- Highlight static blog page link in header
- What file is the standard frontpage that lists all the posts?
- wp_insert_post_data: Limit number of Page but Post get affected
- Conditional Tag for has post [closed]
- Possible to add a statement to a core file?
- older blog posts not showing in new theme
- Is there any way to stylize articles one by one?
- get_children returns older images
- How to display post title inside thumbnail?
- Banner appearing on Pages but not Posts; call it conditional confusion
- Single post full screen template not inheriting WordPress role permission
- how do I get the title in the post [closed]
- Publish a Silent Post without updating Feed
- How to display a single(current) post from a category
- Delete post from admin but not from database
- Open a wordpress single post in a lightbox without the header and footer
- how many visitor open this post? [closed]
- how to create a sub section in posts
- Separate top level categories on archive-product.php by meta
- How to add text before post_excerpt in Gutenberg
- While loop in functions.php outputting the_title() of each post on frontpage
- Pinterest button shows image options from different posts
- Execute php after post save/update
- allow user to create a draft post but not publish wordpress
- Ignore posts content in the posts queries for internal linking
- Comments are in database, don’t show up in WordPress backend or frontend
- Many buttons not functioning in WordPress dashboard (as admin)
- Is there a way to save different data when USER interacts with the same POST?
- WP_Query that targets all categories
- Fill the exclude array() in get_posts()
- Prevent Archive URLs
- Dev and prod on the same database- dev version active for IOS
- Prevent WordPress from putting around specific element
- How to put the WordPress blog into theme
- How to correctly escape data
- How to fetch posts that are stored in the different table than the default table (wp_posts)?
- Sort Events by Venue Title – Sort Post set by related post ids
- Custom layout manager for posts
- Get posts by category or author
- How to make post button to a random post
- I moved my site to another server, wp admin works so does the front page, but posts don’t work
- How can I have the posts from one word press blog show on the presentation page of another word press site
- Where is object, property or label in the database that controls the order of the posts being displayed?
- How to pass multiple checkbox values to wordpress query?
- How to create three columns from selected posts
- Display the popular tags by default in the backend post edit page (without having to click on the link that displays them) [closed]
- How to get single post by one author?
- Getting 404 when using rewrite rule for posts
- Posts and pages not getting published
- How to create a post based on data in a table?
- Display all posts from selected month
- How to make category for word post_content
- How does WordPress add the comments and comment form to posts
- how to change background color of my all post