Prevent Archive URLs

WordPress generates date archives automatically, it’s just a thing it does. You see the index.php template probably because there isn’t a more specific one for date archives in your current theme. There are plugins that disable these archives, Yoast SEO is one. A quick fix is to empty the date archive rewrite rules: add_filter( ‘date_rewrite_rules’, … Read more

How to make a page show posts only from specific categories without editing php files

You can use WP_Query to lists posts with excerpt from specific category. Here is sample code: <?php $args = array( ‘posts_per_page’ => -1, ‘cat’ => 7, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘post_status’ => array(‘publish’, ‘draft’, ‘pending’ ), ‘author’ => 1, ); $postslist = get_posts( $args ); foreach ( $postslist as $post … Read more

Fill the exclude array() in get_posts()

After three days of struggling and posting a question here I managed to find an answer. Yeh I know… To my defense I can say that it’s my first WP project. I did it this way: $exclude = get_excluded_parents(); $parents = get_posts( array( ‘post_type’ => ‘jhk_story’, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘numberposts’ => -1, … Read more

Limit amount of categories displayed in a post

In your functions.php, you can filter the_category_list, which is an array of categories for a post. function wpse_the_category_list( $categories, $post_id ) { return array_slice( $categories, 0, 2, true ); } add_filter( ‘the_category_list’, ‘wpse_the_category_list’, 10, 2 ); And then display the categories in your template file with: the_category();

‘posts’ table should not store the absolute image path

Well, after a little research I realized that it is an (inconvenient) feature of WordPress to store the absolute path of the images and other files, something that I completely disagree with. In any case, I discovered this plugin https://wordpress.org/plugins/root-relative-urls/. It does not fix the urls of files already inserted, but it corrects those of … Read more