Missing ‘Page Attributes’
This works: <?php /* * Template Name: Top Ten * Template Post Type: post, page, product */ get_header(); ?> I was missing the Template Post Type
This works: <?php /* * Template Name: Top Ten * Template Post Type: post, page, product */ get_header(); ?> I was missing the Template Post Type
You can simply right click on your Template Select on the edit page, Inspect Element (on Chrome) then you can check the different options in the select like “page-template.php” as value and find your template file. 🙂 <select id=”inspector-select-control-0″ class=”components-select-control__input”> <option value=””>Default</option> <option value=”page-my-account.php”>My Account</option> </select> It should look like this with your own templates.
Using the following code I was able to load the custom template. public function register_hook_callbacks(){ // Enqueue Styles & Scripts. add_action( ‘wp_enqueue_scripts’, array( $this, ‘enqueue_scripts’ ) ); add_filter(‘template_include’, array( $this, ‘view_project_template’) ); }
/** * Filters list of page templates for a theme. * @param string[] $post_templates Array of template header names keyed by the template file name. * @param WP_Theme $this The theme object. * @param WP_Post|null $post The post being edited, provided for context, or null. * @param string $post_type Post type to get the templates … Read more
You corrected the filter hook name from archive-videos to template_include, but in the first function return $query; statement comes before add_filter(), so the filter is not added. add_action( ‘pre_get_posts’ ,’post_type_videos’ ); function post_type_videos( $query ) { if ( ! is_admin() && $query->is_post_type_archive( ‘videos_cpt’ ) && $query->is_main_query() ) { $query->set( ‘post_type’, ‘videos’ ); //set query arg … Read more
I’ve taken the answer from here, where they are changing the order in a different way, but it should work for you. It uses the pre_get_posts hook to change the ordering for the archive page only. add_action( ‘pre_get_posts’, ‘my_change_sort_order’); function my_change_sort_order($query){ if(is_archive()): //If you wanted it for the archive of a custom post type use: … Read more
You could try to use the is_page() function – https://developer.wordpress.org/reference/functions/is_page/ The function signature accepts one parameter – $page (int|string|int[]|string[]) (Optional) Page ID, title, slug, or array of such to check against. Default value: ” if ( is_page(‘account’) ){ // do some code here }
Glad that you managed to figure out a solution, which yes, does work. But you could make it more selectively, i.e. target just the specific pages, by using is_single( ‘<parent slug>/<child slug>’ ), e.g. is_single( ‘family-law/success-stories’ ) in your case. Secondly, it’s not exactly the redirect_canonical hook which caused the (301) redirect on singular paginated … Read more
Short answer: kinda The visual editor is the open source Tiny MCE WYSIWYG editor. You can style it however you want (i.e. so that it presents the same colors and fonts as the finished posts and pages) by writing a stylesheet to do so and loading it with the add_editor_style hook. However, it sounds more … Read more
The basic answer – you can easily load template (or any PHP file really) with *drumroll*load_template(). 🙂 As for best way to implement your custom feed, I think it would make sense to do it by analogue with native WP feeds. You register feed name and handler function with add_feed() and load template in that … Read more