Adding a text link under the post title in the lists of posts

You can enhance, change the strings to each post title in the table view of backend on post via hook: add_filter( ‘post_row_actions’, array( $this, ‘add_archive_link’ ), 10, 2 ); See the result in this screenshot: Below you find my method to add a link /** * Add link on archive * * @uses get_post_type_object, get_archive_post_link, … Read more

How to get the post’s parent ID?

WordPress 5.7 introduces a new helper function to more easily fetch the parent post’s ID: get_post_parent() This can also be used in conjunction with has_post_parent(), so you could have something like looks like: <?php if ( has_post_parent() ) : ?> <a href=”<?php the_permalink( get_post_parent() ); ?>”> <?php echo sprintf( esc_html__( ‘Back to parent page: %s’, … Read more

Displaying a widget only on long posts (over X characters)

Use the function t5_word_count() from this answer and extend the method widget() in your widget class: public function widget( $args, $instance ) { if ( ! is_singular() ) return; $content = get_the_content( ”, TRUE ); $words = t5_word_count( $content ); if ( 50 > $words ) return; // print you widget }

Notification to Admin or Author upon new post [duplicate]

You need to write your hook for transition_post_status action: function authorNotification( $new_status, $old_status, $post ) { if ( $new_status == ‘publish’ && $old_status != ‘publish’ ) { $author = get_userdata($post->post_author); $message = ” Hi “.$author->display_name.”, New post, “.$post->post_title.” has just been published at “.get_permalink( $post->ID ).”. “; wp_mail($author->user_email, “New Post Published”, $message); } } add_action(‘transition_post_status’, … Read more

setup_postdata doesn`t seem ot be working

According to the Codex, you seem to skip the most important global $post; at the beginning, like this: global $post; $posts = get_posts($args); foreach($posts as $post) { setup_postdata($post); ?> <article class=”col two tablet-four mobile-six box”> <a href=”https://wordpress.stackexchange.com/questions/131909/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <div class=”featured-image”> <?php if(has_post_thumbnail(get_the_ID())): ?> <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), array(650,200)); ?> <div style=”background: … Read more