Automatic Table of contents with categories and posts

Here is a plugin that does the same. function get_posts_per_taxterm($taxonomy, $term_id ){ $posts = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, ‘field’ => ‘term_id’, ‘terms’ => $term_id, ‘include_children’ => false ) ) ) ); // `first_post_id` is a global variable which … Read more

Pagination (on the static front page) shows always the same posts

https://codex.wordpress.org/Creating_a_Static_Front_Page Static front pages are not intended to be paged. None of the WordPress Previous / Next page link functions work with a static front page. Pagination on a static front page uses the page query variable, not the paged variable. See the WP_Query for details. https://codex.wordpress.org/Class_Reference/WP_Query Display posts from current page on a static … Read more

Secretly passing post ID/title etc into a shortcode form automatically to link submission to post

If you put a unique placeholder value there, you can do a find/replace via the_content filter, which runs after the shortcode is rendered, but before the content is output in the template. For example, this will replace any occurrence of replacethisthing with the post ID: function wpd_replace_something_in_the_content( $content ){ return str_replace( “replacethisthing”, get_the_ID(), $content ); … Read more

view a list of 3 future post, from the nearest to the most far

You should be able to get the next 3 posts by requesting the future status. $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘future’, ‘posts_per_page’ => 3, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ); $future_posts = new WP_Query( $args ); References WP_Query parse_query() (details on the available arguments) Post Status » Future

Next / Previous post in a single category

You can use the combination of in_same_term and excluded_terms. First of all, you have the ID of the category you want to display post from. Next, get all the id of the category of the post by using wp_get_post_terms You can iterate through the returned terms and build an array of terms that you want … Read more

Unable to get all the Posts Attachments

I think you’d have an easier time if you used: $wpdb global $wpdb; $table_name=”posts”; // change this to your post-table name, it may be something different. $values = $wpdb->get_results( “SELECT * FROM $table_name where post_type = attachment”); foreach ($values as $value){ print_r($value); } If you’re seeing unexpected values, then you’ll need to figure out if … Read more