WordPress’ visual editor messing up my (nested) lists (and other things as well)

Instead of using the “type” attribute, try adding a CSS class and styling that. <ol> <li>Number one</li> <li>Number two <ol class=”lower-alpha”> <li>Lowercase a</li> <li>Lowercase b <ul> <li>Paragraph 1</li> <li>Paragraph 2</li> </ul> </li> </ol> </li> </ol> Then in your CSS – depending on your site setup, you may want to add Custom CSS through the Customizer, … Read more

Related posts loop based on tags AND categories doesn’t work without at least one tag assigned

You haven’t accounted for the case that there are no tags assigned in your declaration of $tag_related_posts. Your get_posts function always returns results in your line of code: $tag_related_posts = get_posts(‘exclude=” . $post->ID . “&numberposts=” . $max_articles . “&tag=’ . $tags_string); If the $tags_string is null, it just returns a random list of posts and … Read more

Enable post revisions for a specific post

Since the check is made in wp_revisions_to_keep($post) in wp-includes/revision.php, and the result is run through a filter, you should be able to do something like this: <?php function wpse_289553($num, $post) { if(in_array($post->ID, array(123, 456, 789))) { return -1; } return $num; } add_filter(“wp_revisions_to_keep”, “wpse_289553”, 10, 2); Set your post IDs in that array and adjust … Read more

Automatic value for custom fields for posts

Try meta_query to get posts having theme_settings_post_show == true (for new posts) and theme_settings_post_show not set at all (for old posts): <?php $queryArguments = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘meta_query’ => array( ‘relation’ => ‘OR’, // value is not set or true array( ‘key’ => ‘theme_settings_post_show’, ‘value’ => ”, // can be any … Read more

Count total number across post types

Why not just get the count for each post type and sum them? function get_all_them_ven_posts(){ $count= 0; $post_types = [ ‘postType1’, ‘postType2’, ‘postType3’ ]; foreach( $post_types as $post_type ) { $count_posts = wp_count_posts( $post_type ); $count = $count + $count_posts->publish; } return $count; }

Diplay comment date on WP_Post_Comments_List_Table

So, it doesn’t appear you can do much “properly” to solve this issue, however, you can take some advice from this answer and apply it to your problem: <?php add_filter( ‘get_comment_author_IP’, function( $comment_author_IP, $comment_ID, $comment ) { global $pagenow; if( is_admin() && ‘post.php’ === $pagenow && isset( $_GET[‘post’] ) ) { $comment_date = do_something_to_get_comment_date($comment_ID); $comment_author_IP … Read more

Exclude child pages from archive.php

Of course it is possible. All you have to do is to set post_parent argument to 0. function remove_children_from_archive( $query ) { if ( ! is_admin() && $query->is_main_query() && is_post_type_archive(‘my_custom_post_type’) ) { // of course you’ll have to change my_custom_post_type to real slug – probably services $query->set( ‘post_parent’, 0 ); } } add_action( ‘pre_get_posts’, ‘remove_children_from_archive’ … Read more

How can I get a post field value using javascript?

Can I use the API and a JS ajax function to get the two values? Yes, absolutely. Step 1: (PHP) Registers the custom fields (i.e. add them to the WordPress REST API response for Posts) register_meta( ‘post’, ‘address1’, [ ‘type’ => ‘string’, // string/boolean/integer/number ‘single’ => true, ‘show_in_rest’ => true, ] ); register_meta( ‘post’, ‘address2’, … Read more