Get URL from all images in a post

You probably can’t find any attached images because those images are not considered ‘attached’ or have been attached to another post before. With this script you can search directly in the_content() for all the attached images and then create another list with only the <img> tags cleaned from the rest of the text. $post_content = … Read more

WordPress post page not working properly

Your first screenshot is the block editor. The new editor introduced in WordPress 5.0. It is the default editor, so yes, it is what you “should” get when creating a post. The second screenshot shows the classic editor, which is often still used for custom post types. If you want to use this editor for … Read more

Very complex post query

I got inspired in solving my problem by this thread! The idea is to create individual queries (unordered to save time, as sorting is not needed at this stage) to get the post IDs that meet your criteria; then take those IDs and run a final query with the IDs as the criteria to get … Read more

Make loop inside slider divisible [closed]

Unfortunatelly, I didn’t understand your question right, but I see only 2 possible problems here. Here you will need to use: $blog->current_post – current post index $blog->post_count – total posts If you need to wrap each 4 posts with a div, and if there are less then 4 posts in the end, wrap them to. … Read more

search blog posts by author first name and or last name

Actually, when you set author_name, WP_Query will use get_user_by( ‘slug’, <author name> ) to find a user with the specified “nice name” (user_nicename) value, and if found, then WP_Query sets the author arg to the found user’s ID. Therefore you can follow the same approach, but you would use get_users() to find users having the … Read more

Shortcode with ‘year’ parameter

With help from @bosco , I was able to figure it out. Below is the working code: //get archived posts per year add_shortcode( ‘archived-posts’, ‘archived_posts’ ); function archived_posts($atts) { $a = shortcode_atts( array( ‘year’ => date(‘Y’) ), $atts ); $q = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1 , ‘post_status’ => ‘archive’ , ‘year’ … Read more