Ajax posts filter by date, comments, top views, top likes

I haven’t tested the code, but this should help. option elements do not have a name attribute: <option name=”top-views” value=”top-views”>Top Views</option> <option name=”top-likes” value=”top-likes”>Top Likes</option> And therefore $_POST[‘top-views’] for example, is not going to be set, or that the value is not the top-views in the above option. Use the proper option markup Based on … Read more

Open Custom Post Type as PDF

You may want to try a few PDF generation plugins out there. I did some quick Googling and found https://wordpress.org/plugins/wp-pdf-generator/ (but I would recommend searching for others). Once installed, you can directly link your users to the “generate pdf” link instead of the Custom Post Type permalink, generating the PDF automatically for them. You can … Read more

Retrieving Author ID in wp-admin area

It can be done like this without having to rely on the $post global. if ( is_admin() ) { if( isset( $_GET[‘post’] ) && isset( $_GET[‘action’] ) && $_GET[‘action’] === ‘edit’ ) { $post_id = $_GET[‘post’]; $current_post = get_post($post_id); $author_id = $current_post->post_author; } } The query string variable post is always the post_id you are … Read more

Can I create a not clickable post?

You can do it in many ways but I think every needs to change your archive template (or other template which display your list). You can use some custom field plugins to add one with “Don’t link do article” and set this in your template in places where you have anchors. That’s a quick solution. … Read more

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

Query all posts of a custom taxonomy term

I believe your issue is with understanding the nature of posts’ hierarchy vs pages’ hierarchy. A page is a type of “post”. It can have hierarchical structure. Posts, by default, do not have hierarchy. So, you would not be able to get post-parents without their children, because the system does not recognize a hierarchy. This … 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