3

That would be because they're using oEmbed, not a shortcode. You should use the function the_content() to render the content of a post, as it applies all the things required to make embeds, shortcodes, etc work properly. If for some reason that's not an option, you can apply the content filter. <?php echo apply_filters( 'the_content', $tpostObj->...


2

Actually, memory was exhausted. Someone has copy-pasted an actual 2MB base64-encoded image into the post content, var_dump was trying to output it. Had to delete the image via PHPMyAdmin, because the WP editor won't open. Once it had been deleted, the problem was gone.


2

Very old query but still there are no direct methods to get all authors with at least one post of 'custom post type'. WP_User_Query also does not support the post type. Using $wpdb will solve the issue. Code: $post_type = 'gutentor';/*Your Post type*/ global $wpdb; $all_authors = $wpdb->get_results( " select A.*, COUNT(*) as post_count from $...


1

If you want to get all the posts by their IDs (regardless of post type) use this: $args = [ 'post_type' => get_post_types(), 'post__in' => [ 43, 23, 65 ] ]; $posts = get_posts($args); Or even shorter: $args = [ 'post_type' => 'any', 'post__in' => [ 43, 23, 65 ] ]; $posts = get_posts($args);


1

How do widgets embedded in a page access posts they should display? That's not how widgets work, and implies there is a framework that provides posts to widgets. There is not. Widgets aren't embedded either, and there is no data source that provides what they should display. Widgets decide that on their own. So if a widget displays the latest posts, it does ...


1

I've taken your code and refactored it. Your nested-for-loops arent the ideal way to go about this. Also, I've used your code and the meta key names exactly as you supplied them, so please double-check they're correct. Some of them are prefixed with the_ and then sometimes not. It's strange, but that's what you supplied. Try the code below to see if you get ...


1

Yes, it is possible, but you will need to register the taxonomy on both sites because switch_to_blog() does not register the taxonomy for you, it mainly only switches the database and yet, taxonomies are not stored in the database, only the terms in the taxonomies. But you don't have to register the taxonomy on page load.. (but yes, that's the proper way to ...


1

You can achieve the OR relation using the tax_query argument like so: $query->set( 'tax_query', array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'terms' => array( 2, 3 ), ), array( 'taxonomy' => 'post_tag', 'terms' => array( 10, 13 ), ), ) );


1

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() ...


1

First, I second Q Studio comment: check Tom McFarlin's post with a warning about using pre_get_posts. More specifically, pre_get_posts works everywhere, including RSS and dashboard, and you might want to exclude your logic from such places. That said, if I understood correctly what you are trying to do, you can achieve it by using author__in parameter of ...


1

You can set the orderby to post__in. Here is a superior post loop: $args = [ 'post__in' => [ 1, 2, 3, 4 ], 'orderby' => 'post__in', ]; $q = new \WP_Query( $args ); if ( $q->have_posts() ) { while ( $q->have_posts() ) { $q->the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php ...


1

Here's an updated version of your code that will get posts that have the Post Format Video and that have the same Categories as the current post in the loop. You'll call wpse_get_video_posts_with_matching_categories() to execute the function. function wpse_get_video_posts_with_matching_categories() { $categories = get_the_category( get_the_ID() ); ...


1

Can you not just go by date? Assuming you made a clean switch from classic to Gutenberg? Otherwise, there's no definitive meta value, but you could just check the post content for common Gutenberg comments, such as <!-- wp:paragraph -->.


1

Must be used inside the loop $post_images = get_children( $post->ID ); $images_count = count( $post_images ); echo $images_count;


1

There is a way to get the SQL query generated by the get_posts() function by using the 'query' filter (since you are not suppressing the filters in you query, the hook will be fired prior to execution of the final SQL query, add_filter('query', 'get_sql'); function get_sql($query){ //check if this is your query, if(strpos($query, "'inst'")>0)...


Only top voted, non community-wiki answers of a minimum length are eligible