How to get all inline images in post content? [duplicate]

Well you can do this 1 of 2 ways. $attachments = get_posts(array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => get_the_ID(), ‘order’ => ‘ASC’, ‘orderby’ => ‘id’, )); And then manipulate the array to remove duplicates. Another option would be to apply a content filter, and use a regex to find and … Read more

Show more than 200 images in one post

Having so many images on one page isn’t recommended. You should split the images into smaller galleries and across more than one page (or use pagination) to lower the page load speed for each page. To split a single post in several pages (adding pagination) you can just add using the text editor. Alternatively ensure … Read more

List all posts, pages and custom post types in admin

There is nothing build-in to create the drop-down for you, so you have to do it yourself. To get the needed information you can use get_post_types() to get the post types you want, set the $args parameter accordingly. Additionally you can set the $ouput parameter to objects, if you need the data provided – it … Read more

Easy reading or transfer of data from posts?

do_shortcode([espro-slider id=21]) will process the shortcode and return the result. The Codex describes exactly this example: // Use shortcode in a PHP file (outside the post editor). echo do_shortcode( ” ); You can often just call the callback directly also: function generic_shortcode_callback($atts,$content) { return “Yay! “.$content; } echo generic_shortcode_callback(”,’ Me!’); VS: function generic_shortcode_callback($atts,$content) { return … Read more

How to check if there are posts with the same tag

this code is with in the loop of single.php , RIGHT? If so then give this code the try , it should work . Problem with your code seems that you are using showpost, rather you should be using posts_per_page Plus i see this fragments of code like `$test = “”; $test .= ‘,’ . … Read more

WP::is_main_query() Not Working

Wrong hook, because what gets passed to wp is the Current WordPress environment instance not The WP_Query instance like it is e.g. passed to loop_start. You could actually just do your check inside the function callback you hook to loop_start. Edit/note: You could just have done global $wp_query; inside the wp hook, it is actually … Read more

How do I switch css class on post

First of all, never use query_posts, use WP_Query to create additional queries. You can target specific post positions in the loop by using the built in current_post var of the query object. Here’s an example using the post_class function: <?php $my_posts = new WP_Query( array( ‘posts_per_page’ => 3 ) ); if( $my_posts->have_posts() ): while( $my_posts->have_posts() … Read more

How to query Posts from a custom post type which contains a custom taxonomy?

You have one or two issues here and possible future bugs that you might encounter term in your tax_query should be terms Be carefull with terms having dates as names and especially dates as slugs. This can cause issues and unexpected results if custom permalinks clash or if something falls into the template hierarchy for … Read more