the_title
doesn’t work that way:
the_title( $before, $after, $echo );
$before
is the text that comes before the title, but you didn’t give it a string/text, you gave it a post object. Post objects aren’t strings, PHP doesn’t know what to do so it stops and prints an error instead.
For the_title
to work, you need to setup the current postdata. Normally a standard loop does this by calling the_post
on the query, but you’ve chosen to use get_posts
instead.
This is what a standard post WP_Query
post loop should look like:
$query = new WP_Query([ ... ]);
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
//.... display post here
}
wp_reset_postdata();
}
Related Posts:
- Stuck in Order by more then one
- Displaying custom field according to date
- Sort a custom post with ACF: Date Picker & Display Featured!
- Group by custom field value (start and end times)
- meta query not retrieving posts
- How to I add count of custom posts listed in a post as a prefix to its title
- Getting custom taxonomy from custom post type
- How to get all children and grandchildren of a hierarchical custom post type?
- Filter next_post_link() and previous_post_link() by meta_key?
- Getting the Intersection of Two Custom Taxonomy Terms for a Custom Post Type?
- Custom Post Type Archives by Date and Taxonomy
- Custom Post Type Archives by Date with Custom Permalink
- Automatically fill custom field value on post publish/update
- Make permalinks based on an ACF-field
- Retrieving 3 latest post from each of 5 different custom post types
- How to sort a table of custom posts by column containing custom field
- List events by month
- Use Custom Post Type as Custom Field
- post__in not taking my list of IDs
- Pull image from ACF field in a Custom Post Type
- Archive filter disappears on no results?
- Custom post admin filtering by post meta (the date)
- WordPress custom post type archive with description
- wp_update_post based function works on existing posts, but not new posts
- How to Display ACF Relationship Custom Field as Link to Specific Custom Post?
- How to replace custom post type slug with an ACF value?
- Link users to a custom post type
- Custom Post type with ACF in REST API, how do I get those values?
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- Validate custom fields before save using WordPress Rest API
- How can I dynamically add a post to a custom post type which uses a custom field?
- Problem with WordPress query on page using custom fields
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- Bulk Update Custom Fields for Custom Post Types
- Troubles with acf/save_post and WP_Query
- Query custom post type with ACF Date
- custom post type WYSIWG removes paragraphs when displayed
- ACF From & To Date Validations
- Query Multiple Custom Posts by Custom Fields
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- CPT archive admin menu label
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Order Custom Post Type by Custom Field Value
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- How to get the intersection of two terms both from different custom taxonomies
- How to update post meta on uploaded image from a custom form?
- Order post by date with ACF
- Adavnced custom fields relationship query plus query inside
- Custom post type showing same Post on all Pages
- How to Make infinite loop of post
- get_posts seems to be skipping the last Post
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- ACF for custom post type archive pages: which hook to use?
- Advanced custom fields Post Object image field not displaying in custom post type single.php
- Sum and count of custom field values
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- Incorrect ordering of custom post type based on time
- Redirect to URL if x number of days passed
- SQL query – get ids – Advanced Custom Fields / WPeC
- date_query empty results with custom post type
- How to set a ‘page’ as parent of a custom post type?
- Custom front-end form for adding post – Category problem
- get_posts() returns empty on custom post type /wp-admin/edit.php
- Query posts by current ACF meta key value on single page as related posts
- Show custom post type event if current day using ACF
- Filter posts by their related field’s custom field
- If ACF Post Object post has custom taxonomy term…
- Changing default admin column sorting to an ACF Date Picker field
- Permalink URL connection between two custom types
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Show specific posts with WP_Query using ACF Post object
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- Custom post type option page template
- Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks
- How to get a custom post type archive paged when using a custom field for post sorting?
- save_post affect creation and deletion
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Can’t pick up a field created with Advanced Custom Fields
- Help ordering custom query by Title, Ascending
- This wp_query will not return any posts and only seems to work with post_status inherit?
- Fetch posts list from fist CPT taxonomy term and list under 2. CPT
- How to query posts by meta keys AND under specific category?
- How to create content automatically when a post is published?
- using ACF datepicker to filter posts on a page
- how to load custom single.php?
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Function that get ACF fields value before saving
- How to query the content of a specific custom post type?
- Custom Post-type not returning the right child_of
- Register a title automatically with a relationship field
- Custom Post Type meta value is being saved in array, instead of just the string (as value)
- ACF – Query relationship without ID
- show custom post’s post in two different divs [duplicate]
- Why custom search engine only searches in post titles of custom posts?
- How to get permalink of post based on post name?
- Post object GUID adding http:/
- Create a hierarchical list of posts that’s grouped and nested by category
- Display custom post type attached media file sizes
- post__in select all custom posts and not the selected array of ids