Updating custom post meta with ajax

If you load a file directly none of the WordPress functions will work. That is why you should nearly always use the AJAX API. The AJAX API solves this problem. Everything loads in WordPress context. You would wrap your processing PHP is a function: function my_ajax_cb_wpse_108143() { $cote = get_post_meta($_POST[‘id’], ‘cote’, true); if($_POST[‘cote’] == ‘like’) … Read more

Template for specific post of custom post type

For the templates WordPress uses, please always refer to Template hierarchy scheme in the Codex. As you can see there, single-{$posttype}-{$slug}.php does not exist, there is only single-{$posttype}.php. To do what you want, have a look at the filter ‘single_template’: add_filter( ‘single_template’, function( $template ) { global $post; if ( $post->post_type === ‘event’ ) { … Read more

Change capability type of post type registered by plugin

@PieterGoosen is cool, and still awake like me and answering like boss. To simplify his code and make it work to this specifically without a bunch of junk on your page: /** * Pieter Goosen writes awesome code */ add_filter( ‘register_post_type_args’, ‘change_capabilities_of_the_custom_css_js_posttype’ , 10, 2 ); function change_capabilities_of_the_custom_css_js_posttype( $args, $post_type ){ // Do not filter … Read more