Display different list of “Custom Templates” for each Custom Page Type
Display different list of “Custom Templates” for each Custom Page Type
Display different list of “Custom Templates” for each Custom Page Type
Try… function maybe_auth_redirect() { if ( is_page_template(‘my-template.php’) && ! is_user_logged_in() ) { auth_redirect(); } } add_action(‘template_redirect’, ‘maybe_auth_redirect’); https://developer.wordpress.org/reference/functions/is_page_template
They do not differ technically. These files exist in your theme directory and the template that loads is determined by the following: If you have a product with slug of dmc-12, then WordPress will first look for a file called single-product-dmc-12.php in the theme directory. If it finds it it will use that template when … Read more
If you are using child theme. Add filter in the functions.php of child theme like this. add_filter(‘get_the_archive_title’,’wpse_224884_filter_archive_title’,10,1); function wpse_224884_filter_archive_title($title){ if ( is_category() ) { $title = sprintf( __( ‘%s’, ‘shaped-blog’ ), single_cat_title( ”, false ) ); } return $title; } Or Copy the entire function into functions.php function shaped_blog_archive_title( $before=””, $after=”” ) { if ( … Read more
Your array is actually two dimensional. It’s in two levels: an array containing an array of four strings. Try echo $result[0][0];
You could try this quick piece of code, it doesnt output to array though. $args = array( ‘meta_key’ => ‘_wp_page_template’, ‘sort_column’ => ‘post_title’, ‘sort_order’ => ‘desc’); $templates = get_pages($args); foreach ( $templates as $template){ $templatePage = $template->meta_value; $templateName = $template->post_name; echo “Named Template: {$templateName} – – {$templatePage}\n”; }
Your first version of no_sidebar_style() looks fine: function no_sidebar_style(){ if (is_page_template(‘page-templates/page-nosidebar.php’)) { wp_enqueue_style( ‘no-sidebar-style’, get_stylesheet_directory_uri().’/css/no-sidebar.css’); } } add_action( ‘wp_enqueue_scripts’, ‘no_sidebar_style’, 19); For debugging, you can use get_page_template() to see the name of the template you’re viewing.
Go to your WordPress dashboard and navigate to Settings >> General, then change the WordPress Address (URL) and the Site Address (URL) from HTTP to HTTPS. Then hit Save Changes button. If your problem is not fixed yet then go to Settings >> Permalinks and hit Save Changes button again. It’ll re-generate your .htaccess file. … Read more
There are many way to do that and WordPress has some default functions to get that parent page. In fact there is a thing called post_parent in post object. However, you can use the below techniques I think- get_post_ancestors( $post ) function. Here $post is ID or object. Here you’ll find the documentation. You can … Read more
how to change custom post type search template to output search results in posttype-archive.php