How to control which category will be picked for the slug of a post?

WordPress picks the lowest ID as its main permalink. However, ALL categories will contain your post automatically. Meaning both these: http://yoursite/category-A/post-A http://yoursite/category-B/post-A …will return your post (given that post-A is in both category-A and category-B) via a redirect. It can’t list them all to you on the Edit page, sorry. But it will make sure … Read more

Reverse chronology of post listing

You can add code below to the beginning of loop.php add_action(‘pre_get_posts’, ‘wpse_change_post_order’); function wpse_change_post_order($query){ $query->set(‘order’,’ASC’); $query->set(‘orderby’,’date’); } the oldest posts will be in the home page.

Email admin when post pending?

There a couple of ways you can go about it depending on your use case and although example number 1 is perfectly valid, it might make more sense to employ the use of example number 2. Example #1: This will send you an email each time a post is updated/published with the status of “pending”. … Read more

Display only posts from a specific parent category

$the_category_id = 10; $new_posts = new WP_Query( array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘terms’ => array( $the_category_id ), ‘field’ => ‘term_id’, ‘operator’ => ‘AND’, ‘include_children’ => false ) ) ) ); So basically the difference is include_children parameter.

Dynamically update post title in admin page

The block editor is restoring back the title that was last saved (or typed manually into the textarea), so with the block editor, you can change the title dynamically using this code: wp.data.dispatch( ‘core/editor’ ).editPost( { title: ‘Title here’ } ) PS: You should make sure your JS file has the wp-editor, wp-edit-post or wp-data … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)