Extending body classes in front- and backend

Your snippet adds the following classes to the body tag on the front end, someText someText Your snippet adds the following classes to the body tag on the back end, someClassA someClassB If that is you intended result, then yes that works and is correct. You could also do, function add_custom_body_classes($classes) { $someClassA = ‘someText’; … Read more

Generate Catalog Of Posts Based On Template

To get all posts ordered by their template you need two functions: one for the query, and one to add a custom order. Get the posts function get_posts_by_template() { add_filter( ‘posts_orderby’, ‘orderby_template’ ); $query = new WP_Query( array( //’meta_key’ => ‘_wp_page_template’, ‘post_type’ => ‘any’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1, // dangerous … Read more

Programatically create a page

You can try // add a new page $args = array ( ‘post_type’ => ‘page’, ‘post_title’ => ‘My New Page’, ‘post_status’ => ‘publish’, ); $pid = wp_insert_post( $args ); // add a custom template file to the newly created page if( $pid > 0 ) add_post_meta( $pid, ‘_wp_page_template’, ‘custom-template.php’ ); where we set the page … Read more

Valid HTML in Template Part

Of course there is. Just do it like this: $sticky = get_option( ‘sticky_posts’ ); $args = array( ‘post_type’ => ‘mission’, ‘ignore_sticky_posts’ => 1, ‘orderby’ => ‘date’, ‘post__not_in’ => $sticky, ‘posts_per_page’ => $count ); $latest_missions = new WP_Query( $args ); if ( $latest_missions->have_posts() ) { echo ‘<ul>’; // prints opening ul tag before list items while … Read more

home.php not loading

You say you copied the entire content of index.php into home.php but I assume you have made some changes? Because if not the pages looks identical so maybe it is loading, but just the same? Now are you having posts or pages you want to display on your front page? Because for the posts and … Read more

How to add posts list to a page template?

In your wp-content/themes/your-theme folder you need create your own page template… CUSTOM PAGE TEMPLATE In the same folder where you just created your new file, you should see a file named page.php. Open that file by choosing to edit it, and then copy everything you find inside of it. Then, at the very top of … Read more