Custom Post Type Navigation on Custom Field

For previous and next post links to work, you need to hook on to the get_*_post_* filters and modify the query to actually sort the posts using your custom field. I hope the code below will work for you. For Previous post link add_filter(‘get_previous_post_join’, ‘wpse96670_get_previous_post_join_custom_sort’); add_filter(‘get_previous_post_where’, ‘wpse96670_get_previous_post_where_custom_sort’); add_filter(‘get_previous_post_sort’, ‘wpse96670_get_previous_post_sort_custom_sort’); function wpse96670_get_previous_post_join_custom_sort($join) { global $wpdb; return … Read more

like to keep reading plugin

There are three major flaws with what you’re asking: 1. You are attempting to use a WordPress API in a file loaded separately from WordPress. This will only work if you include WP in that file (resulting in the performance difference you likely expected to gain by loading a static file vs. a page/post being … Read more

How to sanitize user input?

I am not sure if this helpful or not. As s_ha_dum said, you should post how you are processing the submitted data and sending to db. But for starters, you might look at escaping the outputted data in the form: <input style=”width:100%” type=”text” name=”dataHow to sanitize user input?” id=”title” value=”<?php $title = get_option(‘data_test’); echo esc_attr($title[‘title’]); … Read more

How to run a external JavaScript file on wp-admin if admin, and other if normal user?

You need to register/enqueue your admin scripts on admin_enqueue_scripts, not on wp_enqueue_scripts. wp_enqueue_scripts is a front end hook. It won’t run on the admin pages. Secondly, is_admin() just checks whether the page is an admin page, not whether the user is an administrator. To check whether the user is an administrator use: $current_user = wp_get_current_user(); … Read more