Hiding Wordpress parent theme - wordpress

I am using the child theme and have renamed it to the new theme name. However, the parent theme is still viewable in the admin area with the original theme name. How do I hide the parent theme? Thanks.

As far as I know this cannot be done. The idea behind child themes is to be Update Safe.
This means, you can update the parent theme and all the child theme functionality goes unaffected. If you want to hide the parent theme, you are better off forking it.

As i seen on wp-admin/themes.php file that wordpress use function called wp_prepare_attachment_for_js to collect the available theme information and then display it on themes page.
The function wp_prepare_attachment_for_js located on wp-admin/theme.php may be line 409 and seems the function have filter wp_prepare_attachment_for_js, so i think this will be done with this filter by unset the selected theme (parent theme to hide) before displayed to the available themes.
try add filter like this to your functions.php
add_filter( 'wp_prepare_themes_for_js', 'test_hide_themes', 11, 1 );
function test_hide_themes($prepared_themes){
// hide parent-theme theme
unset($prepared_themes['your-parent-theme-slug']);
return $prepared_themes;
}

Related

Child Theme Index.php won't override parent theme

So I've built several sites like this, using a child theme to be able to customize what I want.
This time, I have a child theme directory with a style.css and functions.php, etc.
The style sheet overrides fine, even the header.php I added overrides. However, index.php will not override the parent theme's index.php.
Anyone have any ideas?
It sounds like you've set everything up correctly, from the fact that your header.php is overriding the parent theme.
The index.php template is the final fallback if Wordpress cannot find a more appropriate template to use. Most likely, it's selecting another template from the parent theme - eg. archive.php, frontpage.php, home.php, single.php - or many others depending on which particular URL you are viewing.
This visual overview of Wordpress' template hierarchy will help you understand how it works. Using this, you should be able to locate which template file is being selected in the parent theme and therefore, which one you need to override.

Woocommerce Mystile Child Theme Not Displaying Correctly

I've created child themes before without issue however when I create one using Woocommerce Mystile theme it does not display properly with menu items missing and images resizing to be too large.
I made the child theme by creating a new folder in the wp-content>themes folder called mystile-child and creating style.css with the contents
/*
Theme Name: Mystile Child
Description: Mystile Child Theme
Template: mystile
*/
I then created a functions.php file with the contents
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
this is what the parent theme looks like:
This what the child theme looks like
Just out of curiousity - were the logo and other missing elements set up intially using the theme customizer (reached via the wordpress admin menu Appearance > Customize)?
If that's the case, then those settings are created outside of your theme and need to be reset or imported for your child theme. There are a few ways to accomplish this, the easiest way being with a plugin which imports/exports those Customizer settings.
Hope that helps,
Laura
Okay I fixed the problem following the advice found on Wordpress.org support forum here https://wordpress.org/support/topic/mystile-theme-child-header-problem
Seems more of temporary fix though and something that the people at Woocommerce should investigate.

What makes a Wordpress theme an "invalid parent theme"?

In order to overwrite some CSS of an existing Wordpress theme, I would like to create a child theme of it as described on http://codex.wordpress.org/Child_Themes#Example_of_a_basic_Child_Theme .
I created a directory along with the style.css file, where the parent theme's name is defined as "template". So far, so good. When I go to the themes page in Wordpress' administration, I get the message "The [name of parent theme] theme is not a valid parent theme.", and I cannot activate it.
I am wondering how Wordpress finds out if a parent theme is valid or not and if there is a way to make the parent theme a valid parent theme.
In order to find out if the defined parent theme is the problem, I replaced the "template" definition with another theme, which is also installed on the same server, and that worked.
Thanks in advance for your help.
It seems I forgot to mention the fact that caused the problem: My parent theme is already a child theme, and I was not aware of the two generation limit, which means that a child child theme is not possible. :-(
Thanks for your help anyway! Maybe this information should be added on http://codex.wordpress.org/Child_Themes ...
try checking your child theme's css and look at the #import line and make sure there is a ';' semicolon at the end. :)
Your child theme needs to use exactly the same name (same cases, same spaces etc.) as the parent theme. It's defined as Theme Name in the parent's style.css.

Can I create new page.php on child theme in wordpress?

I would like to create new page (with specific style) on child theme. I created a page.php on child theme, however, it doesn't work. Instead of, parent theme's pape.php does.
When I remove the parent theme's pape.php, it redirects index.php.
Can I create new page.php on child theme in wordpress?
Sounds strange. As i understood you can overload all the files in your parent-theme from the child-theme by just creating a new -filename-.php. Here is som good reading Wordpress Child Theme

Drupal administration theme doesn't apply to Blocks pages (admin/build/block)

A site I'm creating for a customer in D6 has various images overlaying parts of the main content area. It looks very pretty and they have to be there for the general effect.
The problem is, if you use this theme in the administration pages, the images get in the way of everything.
My solution was to create a custom admin theme, based on the default one, which has these image areas disabled in the output template files - page.tpl.php
The problem is that when you try and edit the blocks page, it uses the default theme and half the blocks admin settings are unclickable behind the images. I KNOW this is by design in Drupal, but it's annoying the hell out of me and is edging towards "bug" rather than "feature" in my mind. It also appears that there is no way of getting around it.
You can edit /modules/blocks/block.admin.inc to force Drupal to show the blocks page in the chosen admin theme. BUT whichever changes you then make will not be transferred to the default theme, as Drupal treats each theme separately and each theme can have different block layouts. :x
function block_admin_display($theme = NULL) {
global $custom_theme;
// If non-default theme configuration has been selected, set the custom theme.
// $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
// Display admin theme
$custom_theme = variable_get('admin_theme', '0');
// Fetch and sort blocks
$blocks = _block_rehash();
usort($blocks, '_block_compare');
return drupal_get_form('block_admin_display_form', $blocks, $theme);
}
Can anyone help? the only thing I can think of is to push the $content area well below the areas where the image appear and use blocks only for content display.
Thanks!
in template.php you can put
function YOURTHEME_preprocess_page(&$vars) {
if (implode('/', arg()) == 'admin/build/block'){
$vars['body_classes'] = $vars['body_classes'].' administer_block';
}
}
and you'll have a nice body class which you can use to hide those images using CSS.
If anyone's still having a problem with this, a bit similar to barraponto's solution above, if you are using the admin menu module, it adds a class (.admin-menu) to the body, which you can use to hide any overlaying divs etc that are getting in the way.
you can apply admin theme wherever you want using hook_init() in your custom module:
function yourmodule_init()
{
if ( some condition here like arg(0) == 'foobar'
or node_load(arg(1))->type == 'something' )
{
$GLOBALS['custom_theme'] = variable_get('admin_theme', '0');
drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
drupal_add_js(drupal_get_path('theme', 'myadmintheme').'/jscripts/adminjs.js');
}
}
EDIT: then (probably) you have to use form_alter against the block editing form to restore the target theme. in this way you don't have to hack the core.
Thanks for bringing up this topic! I was having the same problem, and it's annoying. Here's how to remedy it without a single line of code:
1) Switch the main theme to your administration theme.
2) Configure Blocks. This always affects the currently selected main theme.
3) Switch the main theme back to what it's supposed to be. Your admin theme will still reflect your changes.
could just use the block-admin..... tpl file from block module and theme it in your custom theme. I have done this way as admin theme module never overrides block admin even when you use custom path bit.
If you don't need your new theme while performing administration tasks, you can use a different theme while doing so.
Goto "Site Configuration" -> "Administration Theme". Here you can pick the theme to be used while doing admin. So your new theme is only used while users are viewing your site. And you can do admin tasks without the interference of all your images.

Resources