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

Downloadable Documents

No need to insert the download into the post as @kaiser says, you can automate: $download = get_children( ‘post_type=attachment&post_mime_type=application/pdf&post_parent=”.$post->ID ); if ($download) { foreach ( $download as $attachment_id => $attachment ) { echo “<a href=”‘.wp_get_attachment_url($attachment_id).'” target=”_blank” class=”download”>Download PDF</a>’; } }

Display posts by tag on page

This should do the job. It’ll check for posts that have been tagged with the title of the current page. There’s no need to use if (have_posts()): on a page template: if the template is called it will be because there is a post 🙂 <div class=”page-loop”> <?php while (have_posts()) : the_post(); $page_title = strtolower(get_the_title()); … Read more