How can I make existing custom fields easier to edit/add in my theme?
In general the answer is yes and the web is full of good tutorials that would do a better job than I can here.
In general the answer is yes and the web is full of good tutorials that would do a better job than I can here.
You’re comparing strings. For dates this will only ever work out if you use a yyyymmdd format or similar.
Look at ‘save_post’ and Post Status Transitions. save_post is an action triggered whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. The data for the post is stored in $_POST, $_GET or the global $post_data, depending on how the post was … Read more
Judging from your site’s content and the comments, you may try using the following CODE in your theme’s functions.php file. It’ll remove empty <p> </p> tags from post content: add_filter( ‘the_content’, ‘wpse_257854_remove_empty_p’, PHP_INT_MAX ); add_filter( ‘the_excerpt’, ‘wpse_257854_remove_empty_p’, PHP_INT_MAX ); function wpse_257854_remove_empty_p( $content ) { return str_ireplace( ‘<p> </p>’, ”, $content ); } However, after it removes the … Read more
The pagination functions work off of the main query, so you’d need to use pre_get_posts instead of creating a new query for them to work. But, you’re using WP_User_Query, so the standard pagination system will never work for you. You’re going to have to ‘roll your own’ pagination system here, and generate your own URLs … Read more
Yep, you’re looking for wp_localize_script(). Do away with the global. add_action( ‘wp_enqueue_scripts’, ‘wpse_enqueue_scripts’ ); function wpse_enqueue_scripts() { wp_enqueue_script( ‘wpse-main’, get_template_directory_uri() . ‘/path/to/script.js’, array(), false, true ); wp_localize_script( ‘wpse-main’, ‘wpseVars’, array( ‘postsLoop1’ => json_encode( /* first post array */ ), ‘postsLoop2’ => json_encode( /* second post array */ ), ‘postsLoop3’ => json_encode( /* third post array … Read more
You can try the –url argument to target a given site in your network: wp post create \ –post_type=page \ –post_title=”ABC” \ –post_status=publish \ –url=http://example.tld/somesite/ where you can view available site urls with wp site list
Use publish_future_post action hook. Contrary to what Codex says, it is not deprecated, and it works with WordPress 4.8.2. Your code should be: function my_test_future_post( $post_id ) { update_post_meta( $post_id, ‘hook_fired’, ‘true’ ); } add_action( ‘publish_future_post’, ‘my_test_future_post’ ); Tested! Update If you are concerned about publish_future_post hook being deprecated, use transition_post_status hook: function my_test_future_post( $new, … Read more
Don’t know if there is an easy way out but you can do this to achieve: Introduce an admin js in your functions.php like this: //Admin JS add_action(‘admin_init’, ‘custom_admin_js’); function custom_admin_js() { wp_register_script( ‘admin-js’, get_stylesheet_directory_uri() . ‘/js/admin.js’ ); wp_enqueue_script( ‘admin-js’ ); } The js file will go in the theme you are using make another … Read more
Sorry, I’ve had to change my answer after checking the WordPress Codex on adding custom editable data to the quick edit. So you’ll have to remove the references to $post_id too (from the add_action arguments and from within your function). It looks like the quick_edit_custom_box only takes 2 arguments: $column_name and $post_type. Then for getting … Read more