Tag Info

New answers tagged

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 ...


0

Well, there is SOLUTION: add_action('init', 'x'); function x(){ remove_all_actions('get_template_part_content'); } add_action('get_template_part_content', 'yourFunc', 99, 2 ); but think carefully, in which hook you should insert that action... also, you can filter content parts, for example: function yourFunc ( $slug, $name ) { .........any codes ...


1

I vote for having two separate pages since this gives you all the power of permalinks that go directly to a specific video. That's much better for you and your visitors since the content can be more easily shared. From the codes perspective, you can apply DRY principles and still use a single-video.php and archive-video.php template. Have a look at the ...



Top 50 recent answers are included