Hide page visual editor if certain template is selected?

add_action( ‘init’, ‘remove_editor_init’ ); function remove_editor_init() { // If not in the admin, return. if ( ! is_admin() ) { return; } // Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, ‘post’, FILTER_SANITIZE_NUMBER_INT ); // Get the post ID on update post with filter_input super global inspection. … Read more

Passing parameters to a custom page template using clean urls

add_rewrite_rule() allows you to turn the pretty url into variables. numbers: (\d*) section: /rid/ or /pageid/ slug: ([a-zA-Z0-9-]+ Here is a class to register the rewrite and handle the request if a match has been found. <?php if ( ! class_exists( ‘CPTURLRewrite’ ) ): class CPTURLRewrite { const ENDPOINT_QUERY_NAME = ‘pageid’; const ENDPOINT_QUERY_PARAM = ‘__pageid’; … Read more

Is it possible to define a template for a custom post type within a plugin independent of the active theme?

You need to use the template_include filter which is the generic filter for all template inclusions. add_filter( ‘template_include’, ‘my_plugin_templates’ ); function my_plugin_templates( $template ) { $post_types = array( ‘project’ ); if ( is_post_type_archive( $post_types ) && ! file_exists( get_stylesheet_directory() . ‘/archive-project.php’ ) ) $template=”path/to/list/template/in/plugin/folder.php”; if ( is_singular( $post_types ) && ! file_exists( get_stylesheet_directory() . ‘/single-project.php’ … Read more

How to redirect to post if search results only returns one post

Add this snippet to your functions.php function redirect_the_single_post() { if (is_search() && is_main_query()) { global $wp_query; if ($wp_query->post_count == 1 && $wp_query->max_num_pages == 1) { wp_redirect( get_permalink( $wp_query->posts[‘0’]->ID ) ); exit; } } } add_action(‘template_redirect’, ‘redirect_the_single_post’ ); hope this will help you!!

Page editor missing Templates drop down

Maybe this will help. <?php /* Template Name: Featured */ get_header(); ?> Regular code here… <?php get_footer(); ?> If one theme works you could try replacing the files in the broken theme and test which file or files are broken. But first save the old files in a separate folder as a backup. Then you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)