Add simple field column to the posts screen

Ref. https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column Just use the WP built in action called “manage_posts_custom_column” and in callback check for the correct column and add simple_field value with the function simple_fields_value : add_action( ‘manage_posts_custom_column’ , ‘add_new_column_data_in_posts’, 10, 2 ); function add_new_column_data_in_posts( $column, $post_id ) { switch ( $column ) { case ‘premium’ : echo simple_fields_value(“simple_field_slug”, $post_id); break; } }

Get all custom posts with a certain taxonomy

The proper argument to your tax query is terms, not term. You can see this in one of the examples in the Codex: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, ‘terms’ => ‘bob’, ), ), ); $query = new WP_Query( $args ); https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters Assuming that your … Read more

How to display multiple images from the post on the homepage

The best way would be how wordpress handle Featured Image in core. They just store the attachment_id in a post meta named _thumbnail_id. You should do the same in your case. But instead of setting featured image(for which WordPress has default functions), you need to create the attachments yourself. You can follow these steps – … Read more

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

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

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