How to show posts ordered by random [duplicate]

query_posts() allows for an argument called orderby, there you can provide how you want your posts sorted. So a solution could look like this $args[‘orderby’] = ‘rand’; query_posts($args); For a full list and explanation of the query arguments, check WordPress Developer Resources on WP_Query

Can I Paginate Post after every 25 tag?

If you looking to split one posts into a few pages, you could use a plugin such as custom next page. Or with the tag without a plugin. If you mean you want 25 posts in page with posts list (archive page) , you could set Pagination, You could see example in cods. Or through … Read more

Integrate video and iframe in a post type gallery

The problem is that image is not a proper mime type. You can see a list of mime-types here – so based off the linked list we need to pass an array of what we need: $supported_mimes = array( ‘image/jpeg’, ‘image/gif’, ‘image/png’, ‘video/avi’, ‘video/x-flv’, ‘video/mp4’, ‘video/ogg’, ‘video/webm’, ); $args = array( ‘numberposts’ => -1, // … Read more

Rewrite Rule to Combine Taxonomy and Post Type

We need to create the WordPress rewrite rule to handle multi-level slugs such as: function cpt_rewrite_rule($wp_rewrite) { $rules = array(); $terms = get_terms( array( ‘taxonomy’ => ‘taxonomy_name’, ‘hide_empty’ => false, ) ); $post_type=”post_type_name”; foreach ($terms as $term) { $rules[‘parent_slug_name/’ . $term->slug . ‘/([^/]*)$’] = ‘index.php?post_type=” . $post_type. “&post_type_name=$matches[1]&name=$matches[1]’; } // merge with global rules $wp_rewrite->rules … Read more

How can i take all ids from untrash_post action?

You can use transition_post_status: add_action(‘transition_post_status’, ‘wpse_handle_untrash’); function wpse_handle_untrash($new_status, $old_status, $post) { // if the post was in the trash, but now is not if($old_status == ‘trash’) { // if you want, you can do something only for a certain post type if($post->post_type == ‘my-desired-post-type’) { // do something echo ‘<script>alert(‘ . $post->ID . ‘);</script>’; } … Read more

Get a list of categories that are related to posts

<!– Display Categories Assigned to a post –> <?php $taxonomy = ‘category’; // Get the term IDs assigned to post. $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( ‘fields’ => ‘ids’ ) ); // Separator between links. $separator=”,”; if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) { $gterms = wp_list_categories( array( ‘title_li’ => … Read more

How to make an image appear as a thumbnail in the blog post?

That’s because you’re using an small image to display in that container, the containers has 1100×300 pixels and you’re using a imagem with 560×315 pixels, so when you resize it lost quality. When working with imagem I recommend you to get a image with at least the same sizes of the maximum sizes that you … Read more

How to delete all posts with dead image urls?

I’m only going to cover this in the broadest terms because I don’t know the details of how the linked images appear in your site, but assuming each post contains one hotlinked image: You need to write a script that loops through all your posts and parses the post content for a non-local URL. It … Read more