Admin Notices don’t display on the admin screen for certain post

I found the answer. Notices in the Block Editor would require JavaScript code. ( function( wp ) { wp.data.dispatch(‘core/notices’).createNotice( ‘error’, // Can be one of: success, info, warning, error. ‘Error Message.’, // Text string to display. { isDismissible: true, // Whether the user can dismiss the notice. // Any actions the user can perform. actions: … Read more

How can I set a Post’s default visibility to private and pending review checked

Found this snippet after more searching: //Force posts of custom type to be private //…but first make sure they are not ‘trash’ otherwise it is impossible to trash a post function force_type_private($post) { if (($post[‘post_type’] == ‘post’) { if ($post[‘post_status’] != ‘trash’) $post[‘post_status’] = ‘private’; } return $post; } add_filter(‘wp_insert_post_data’, ‘force_type_private’); Changed the boolean to: … Read more

Adding parent pages to posts

Changing any URLs will have an effect on your SEO. So, if you want zero effect on SEO, you cannot also change URLs from example.com/post to example.com/blog/post. You’ll want to look at how well-established your site is – if you have hundreds or thousands of posts that are ranking well, you likely should not change … Read more

Update admin side post list count text

A simple change would run via javascript, but run lately and in dependence that Javascript is active on the user side. The WordPress way is to use filters to change this text. However, this is a topic in context performance and should look in this direction. This is the typical code snippet to change text. … Read more

List posts in a given category

You are already passing category in $args. so not need to use get_categories(). You can use below code. $args = array( ‘cat’ => 5, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); $custom_loop = new WP_Query($args); if ($custom_loop->have_posts()) { echo “<ul>”; while ($custom_loop->have_posts()) { $custom_loop->the_post(); echo ‘<li><a href=”‘ . get_permalink() . ‘”>’ . … Read more

Multisite – Get current post id

try this $sites = get_sites(); global $switched; /** @var WP_Site $site */ foreach ($sites as $site) { if ( $site->archived || $site->spam || $site->deleted ) { continue; } switch_to_blog( $site->blog_id ); $all_posts = get_posts(‘category=-3&numberposts=6&orderby=post_name&order=DSC’); ?> <ul> <?php foreach($all_posts as $post) : setup_postdata($post);?> <li> <a href=”https://wordpress.stackexchange.com/questions/354427/<?php echo get_page_link($post->ID); ?>” title=”<?php echo $post->post_title; ?>”><?php echo $post->post_title; ?></a> … Read more

Can’t Delete or find a blog post (unknown)

We don’t really know why this post is there but inaccessible by you, but for anyone having this issue here’s how you can attempt to remove it. You would go to any other post in your dashboard/admin, to edit it. In your browser URL bar you’d look for this aspect of the URL: post.php?post=xxxx&action=edit Then, … Read more

Add icon/badge next to posttitle of specific category

This will depend on how your theme is structuring the templates for single.php (individual post view) but I’ll show you what to look for and how to apply via CSS. So from a theme I’m working on, this is where the category gets included in the post: <article id=”post-3417″ class=”post-3417 post type-post status-publish format-standard hentry … Read more

Uppercase first sentence in every post

Welcome to WPSE. So I can’t write all the code for you, but I would suggest you look at these main pieces, and then come back here or make new questions if you have followup questions: To alter the content of a post before it’s printed to the screen you could use the the_content filter. … Read more

Register post status, exclude from searches

If it was me, I would probably just override the queries on the individual templates that you are trying to hide “ghosted” posts on. However, I can see how in some situations it would be better to override the main query. How about: function public_query_published_only($query) { if ( !$query->is_single() && !current_user_can(‘manage_options’) && !is_admin() ) { … Read more