Looks like you’re using both get_posts() and new WP_Query() — You only need one or the other. You’re also using WP_Query() incorrectly — It’s looking for an array of arguments, but you’re passing $videos, which is an array of post objects.
Try this:
<?php
$args = array(
'post_type' => 'videos',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'speaker',
'value' => get_the_ID()
),
array(
'key' => 'events',
'value' => $eventid
)
)
);
$videos = new WP_Query($args);
if($videos->have_posts()) :
while($videos->have_posts()) :
$videos->the_post();
?>
<!-- STUFF FOR EACH VIDEO HERE -->
<a href="https://wordpress.stackexchange.com/questions/121699/<?php the_permalink(); ?>" ?>"><?php the_title(); ?></a>
<?php
endwhile;
endif;
?>
Untested. Hope it works for you.
Related Posts:
- Getting custom taxonomy from custom post type
- Filter next_post_link() and previous_post_link() by meta_key?
- Automatically fill custom field value on post publish/update
- Make permalinks based on an ACF-field
- How to sort a table of custom posts by column containing custom field
- List events by month
- Use Custom Post Type as Custom Field
- Pull image from ACF field in a Custom Post Type
- Archive filter disappears on no results?
- Show ACF field from custom taxonomy and display on the single template
- 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?
- Show custom field from custom taxanomy term on custom post type
- How to replace custom post type slug with an ACF value?
- How to create an array for a CPT post ID to use in an IF/WHILE statement
- 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?
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- 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
- 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 update post meta on uploaded image from a custom form?
- Order post by date with ACF
- How to set the seo title tag on a page by page basis?
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Querying & displaying custom post type into an existent page [closed]
- Custom post type showing same Post on all Pages
- Post loop count is not in order
- How to inherit field value from parent post into in child / sub post
- ACF for custom post type archive pages: which hook to use?
- How to use single.php for creating, reading and editing Custom Posts with ACF
- posttype and custom fields on multisite
- 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
- Custom fields not showing in custom post type
- meta query not retrieving posts
- Using WP meta query to show custom post types by a start and finish date
- Advanced custom field – posted fields from custom post type
- How to display author details in a custom post type in the wordpress backend?
- Show/hide posts and categories based on user meta
- ACF – Retrieve custom taxonomy from a relationship field
- How to set a ‘page’ as parent of a custom post type?
- Custom front-end form for adding post – Category problem
- Set up a WP Cron scheduled event to update calculated ACF field
- Show Post Revisions on front-end
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Add custom post related by custom field to custom post
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Query posts by current ACF meta key value on single page as related posts
- Show custom post type event if current day using ACF
- Issue to display Permalink (ACF Relationships in Custom Post Type )
- 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
- Taxonomy shows up twice on Custom Post Type
- Permalink URL connection between two custom types
- Create 3 Levels of relations with WordPress
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Show specific posts with WP_Query using ACF Post object
- 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
- Linking posts together with Advanced Custom Fields “both ways”
- How to get a custom post type archive paged when using a custom field for post sorting?
- save_post affect creation and deletion
- How can I save a Custom Post Title and Slug with a Custom Field?
- Custom Field as Custom Post type element class
- Extracting Post ID and passing through as an attribute in a shortcode
- Can’t pick up a field created with Advanced Custom Fields
- How to query posts by meta keys AND under specific category?
- 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 adding additional markup
- Advanced Custom Fields: query posts filtered by multiple field values
- Custom Post-type not returning the right child_of
- Register a title automatically with a relationship field
- ACF – Query relationship without ID
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- Display ACF object field data using Elementor Custom Query
- ACF Pro simple Business Directory – Requesting assistance with created Templates and associated Functions.php Coding
- Advanced Custom Fields Custom Post Types Heirarchy
- Generate Post Title From ACF Fields on Custom Post Type