Change path of the page’s template

You can place the page templates wherever you want (also in a separate folder) as long as the files are within the current or parent theme’s directory. UPDATE: Follow this link to get a more detailed information about the Template File Folders: http://codex.wordpress.org/Page_Templates#File_Folders Take also a closer look at the Page Templates and the default … Read more

Programatically switch page template?

you can use template_redirect action hook to php include your maintenance mode template file using a simple option in options database. When you turn maintenance mode on add an option for example: add_option(‘maintenance_mode_on’); then with this code you check if that option is set and if so you redirect to your desired template file: function … Read more

Customize edit.php Pages listing in dashboard to show only pages with a particular template applied?

Try this: <?php // add submenu page add_action(‘admin_menu’, ‘add_template_submenu’); function add_template_submenu() { add_pages_page( ‘My Template’, ‘My Template’, ‘edit_pages’, ‘edit.php?post_type=page&template=your-template-file.php’); } // check for the template name passed in $_GET and add it to the query add_filter(‘parse_query’, ‘filter_pages’); function filter_pages($query) { global $typenow, $pagenow; if ($pagenow == ‘edit.php’ && $typenow == ‘page’ && $_GET[‘template’]) { $query->query_vars[‘meta_key’] … Read more

How to handle a missing page.php?

The only required template in a WordPress theme is the index.php. And a comments.php if comments are supported. Following the template hierarchy, all other files, including page.php, will fall back to the index.php. When a theme doesn’t have a page.php, look at the index.php. There you will find the basic structure for its content. In … Read more

How to list all titles of posts on a specific page?

Paste this into your page template. It will output a list of all posts (without pagination). <?php // the query $all_posts = new WP_Query( array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1 ) ); if ( $all_posts->have_posts() ) : ?> <ul> <?php while ( $all_posts->have_posts() ) : $all_posts->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/240419/<?php the_permalink(); ?>”><?php … Read more

How to edit 404 content via wp editor?

Found a way. Create a regular page for 404 content, say ‘Page not found’; In your 404.php file, get that page data and then write down your content or whatever… For example: $page = get_page_by_title(“Page not found”); if($page) echo apply_filters(‘the_content’,$page->post_content); Obviously, you can do a lot more…

How do I add a body class to specific pages?

add_filter(‘body_class’,’cp_new_body_classes’); function cp_new_body_classes($classes) { if( !is_page_template() ) $classes[] = ‘reg-page’; return $classes; } The problem was that you are only returning the classes if !is_page_template(), but you want to return the classes always as it contains the other classes you didn’t add yourself in an array, you just want to add some then return them … Read more

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