Get how many days since last post of the current user

You can use a modified version of this answer by @s_ha_dum. Where instead of an option you can setup a user meta (even if meta query is slower than option query) add_action(‘save_post’, ‘user_last_update’, 10, 2); function user_last_update($id, $p) { if ( (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) || (defined(‘DOING_AJAX’) && DOING_AJAX) || ($p->post_status !== ‘publish’) ) { return; … Read more

add_meta_box: Datepicker like the one for postdate?

Never really thought about it, but it should indeed be a good option. The date picker is called from wp-admin/includes/meta-boxes.php (line 183) as: <div id=”timestampdiv” class=”hide-if-js”><?php touch_time(($action == ‘edit’),1,4); ?></div> and touch_time() is defined in wp-admin/includes/template.php (line 550) as: /** * {@internal Missing Short Description}} * * @since 0.71 * * @param unknown_type $edit * … Read more

Post custom permalink results in 404 for archive page

You can override the Post type object settings in the init action and register the proper values for the archive and rewrites: add_action(‘init’, ‘my_init’); function my_init() { $args = objectToArray( get_post_type_object(‘post’) ); $args[‘has_archive’] = ‘news’; $args[‘rewrite’] = array( ‘slug’ => ‘news’, ‘with_front’ => FALSE, ); register_post_type(‘post’, $args); } function objectToArray( $object ) { if( !is_object( … Read more

Multiple loops in same page, without duplicate content

it is important to read this Codex chapter all the way to the end, as the essential suggestions are after this heading ‘Note for Multiple Posts in the First Category’; repetitive, tedious code: <?php $do_not_duplicate = array(); ?> <?php $mosaics = new WP_Query(‘category_name=mosaics&posts_per_page=5’); ?> <?php while ($mosaics->have_posts()) : $mosaics->the_post(); ?> <?php $do_not_duplicate[] = $post->ID; ?> … Read more

Restrict access to the Trash folder in Posts

With the filter we prevent the Trash link from being printed. And with the action, redirect back to the post listing page if the user tries to access the URL directly (/wp-admin/edit.php?post_status=trash&post_type=post). add_filter( ‘views_edit-post’, ‘wpse_74488_remove_trash_link’ ); add_action( ‘admin_head-edit.php’, ‘wpse_74488_block_trash_access’ ); function wpse_74488_remove_trash_link( $views ) { if( !current_user_can( ‘delete_plugins’ ) ) unset( $views[‘trash’] ); return $views; … Read more

Possible to create a permalink to sort with meta_key?

What about something like that? function wpse139657_orderby(){ if( isset($_GET[‘orderby’]) ){ $order = $_GET[‘order’] or ‘DESC’; set_query_var(‘orderby’, ‘meta_value_num’); set_query_var(‘meta_key’, $_GET[‘orderby’]); set_query_var(‘order’, $order); } } add_filter(‘pre_get_posts’,’wpse139657_orderby’); In this way you can call your urls with a ?orderby=rank suffixed and it should do the trick. You can also have an optional order parameter, should you want to implement … Read more

Insert code when users come from an specific referer

Your post does make sense, you just want to change/add some content based on referrer, which is very common among websites. Now, as you asked just at the start of body. I don’t believe there is any standard hook in there, other than get_header();. This function is usually located at the very beginning of most … Read more