Tag Info

New answers tagged

-1

You can create a custom template in the theme and give options for each category to select the template. The custom fields for a category can be added using, 'Advanced Custom fields' plugin or you can refer this article. Once you do this, you need to edit the 'category.php' file, to set the template for the category. You will have to use the custom field ...


2

You could use the filter theme_page_templates present since 3.9.0 like so: function my_theme_page_templates( $page_templates, $this, $post ) { $travel_blog_id = 2; $blog_id = get_current_blog_id(); if($blog_id != $travel_blog_id) { if(isset($page_templates['page-travel.php'])) { unset($page_templates['page-travel.php']); ...


0

I think you are doing this right... but in the wrong direction. What if you separate your default structure like: content-header.php <?php get_header(); get_sidebar(); ?> <div id="content"> content-footer.php </div> <?php get_footer(); ?> And then you can use get_template_part to put all together: index.php <?php ...


1

I try this code and it solve my problem if ( is_child_theme() === false ) { // files moved } else { // do nothing } Thankx to @birgire


0

You could try the following: add_action( 'switch_theme', function( $new_name, $new_theme ) { if( is_a( $new_theme->parent(), '\WP_Theme' ) ) { // Child theme was activated } else { // Parent theme was activated } }, 10, 2 ); to see if the theme you just activated is a child theme or not.


0

The name you are using for taxonomy isn't allowed. register_post_type() $taxonomy parameter says $taxonomy (string) (required) The name of the taxonomy. Name should only contain lowercase letters and the underscore character, and not be more than 32 characters long (database structure restriction). Default: None So, you need to change the ...


0

For question as stated it would be easiest to retrieve page's slug and pass it as second argument: get_template_part( 'content', get_post_field( 'post_name', get_post() ) ); Note that you would want to have generic content.php for pages that don't have dedicated template (if any).


0

I tried to add the templates usage info, directly into the template dropdown, with the theme_page_templates filter: add_action( 'load-post.php', function() { add_filter( 'theme_page_templates', function( $page_templates, $obj, $post ) { foreach( $page_templates as $key => $template ) { $posts = get_posts( ...


4

What you need to do is compare the values of the meta field _wp_page_template, which contains the page template selected for a single page with the available page templates. For this you need to construct an array of used templates, because you want the templates used by all the pages, similar as shown here: Return all custom meta data for one custom ...


0

Usually the format you see in themes are content-{$post_format-term}.php or content-{$pagename}.php, but it is not restricted to this formats. The naming convention can also differ to your liking as long as you keep it out of normal template hierarchy and then use get_template_part to call it correctly. These are not self standing templates, they cannot ...


0

The WordPress doesn't operate with concept of partial content. The content of the post is seen as single block of text/markup, possibly with embedded external elements. Even in latter case that is considered one way flow — content output will process embeds, but embeds aren't meant to be extracted from content. In your case I would guess the data ...


0

This is what I´ve done so far, I won't mark as correct answer yet in case there is a better approach that Im not aware. add_action('wp_enqueue_scripts',array( $this, 'remove_all_actions'), 99); public function remove_all_actions(){ if( 'custom-template.php' != get_page_template_slug( get_queried_object_id() )) return; global ...


0

It seems a little odd to only offer the admin bar for a page, but the easiest solution I can think of would be to use conditional functions to deregister scripts/styles and create custom template files for this specific page. Unfortunately, you'll have to figure out all the styles/scripts that are loaded add_action('init', 'remove_all_the_things'); ...


0

Just changed permalink settings ti default and then changed them to post_name and then it worked fine. page templates were created fine and taxonomy were registered fine as well. issue was with .htaccess file.


0

I think you are using brand taxonomy for the post type product. You should create a file taxonomy-brand.php in your theme directory to display whatever you want in this page. You need not to create page template with this name, only create a file with this name in your theme. If you create any page by name brand please rename or delete it because page ...



Top 50 recent answers are included