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

Create a page without adding a page in the Database

To wit, this technically isn’t a ‘page’, however it’s a way to surface content using mod_rewrite. The goal here is to add a URI segment of foobar that will trigger a custom query, then include the specified template file. Add a rewrite rule: add_action(‘init’, ‘foo_add_rewrite_rule’); function foo_add_rewrite_rule(){ add_rewrite_rule(‘^foobar?’,’index.php?is_foobar_page=1&post_type=custom_post_type’,’top’); //Customize this query string – keep is_foobar_page=1 … Read more

Access the same page from multiple urls (wildcard)

You can use template_include, but before you hook to this filter you must do the following steps: Create page template. e.g: page-target.php <?php /** * Template Name: Page Target */ … Manually query the contents of target-page on page-target.php template, because the global $post will be referencing to your some-prefix-* page. (Optional): Edit and apply … Read more

Proper way to get page content

Just to clarify: You mixed two things here. qTranslate stores the different languages in the same post. If you call get_content(), $post->content or an other direct query, you will get the whole content with all different languages from the database. What qTranslates do, it creates a filter-hook which is attached to the_content hook. If somebody … Read more

Listing pages which uses specific template [duplicate]

You can do this with a WP_Query meta_query. The page template filename is stored in post meta under the key _wp_page_template: $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘_wp_page_template’, ‘value’ => ‘product.php’ ) ) ); $the_pages = new WP_Query( $args ); if( $the_pages->have_posts() ){ while( $the_pages->have_posts() ){ … Read more