In what context should Categories and Tags be used

I think this is more a general question than a specific one and I’ll be treating it as such. Taxonomies in general are used to group posts together that shares the same characteristic. The post_tag and category taxonomies are the most widely and commonly used of the four build in taxonomies to achieve this. Also … Read more

What function publishes a post when you click the publish button?

Normally, posts are published by the wp_insert_post() function. Essentially, the post_status is changed from draft to publish. Nothing more to it than that, really. There is also the wp_publish_post() function, which is really only used for scheduled posts. It does the basic job of transitioning a post from “future” to “publish”, and also calls the … Read more

Post deleted in trash [closed]

Once a post is moved to the trash and deleted, it’s gone from the database. The only way to recover it is from an earlier database backup. Do you have a backup? Does your webhost have a backup?

WP_Query custom field pass the post id

1st query: $exclude_post_top_stories=””; // WP_Query arguments $args = array ( ‘post_status’ => array( ‘publish’ ), ‘posts_per_page’ => ‘-1’, ‘order’ => ‘DESC’, ‘orderby’ => ‘date’, ); // The Query $exclude_query = new WP_Query( $args ); // The Loop if ( $exclude_query->have_posts() ) { while ( $exclude_query->have_posts() ) { $exclude_query->the_post(); // do something $exclude_post_top_stories[] = get_the_id(); } … Read more

Copy/Move selected taxonomy terms to another taxonomy for posts

This will get all posts with $old_tax, copy the terms from $old_tax to $new_tax, and then set the $new_tax terms for those posts. <?php function convert_tax($old_tax, $new_tax) { $pages = get_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => $old_tax, ‘operator’ => ‘EXISTS’ ) ) )); foreach($pages as $post) { $terms … Read more

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; } }

I would like to remove date display on photo preview

There are two possible solutions: CSS edit and File edit. CSS edit(Not the best solution, but works) .post-blocks .block-info span { display: none; } It is not possible for us to write the file edit code since we don’t have access to your admin panel. Install WhatTheFile plugin to find out the template that renders … Read more

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