Changing Default Pages' Permalink (El Greco Theme)

E

Ekaterina Sayapina

Guest
Hi Ekaterina,

It worked. But it will be lost after updating.

Could you offer a copy of a child theme functions.php script that works with El Greco?
Hello ThiagoN,

I'm sorry for the delayed reply.
We've got a detailed guide on how to create a child theme, please feel free to check it out. All you need to do is to copy the desired php file in your parent theme and add it to your child theme. Be sure to stick to the parent theme structure. For example, if the php file is located in the parent theme folder, do not add it to a child subfolder.
Hope this helps.
 

ThiagoN

New Member
Hello ThiagoN,

I'm sorry for the delayed reply.
We've got a detailed guide on how to create a child theme, please feel free to check it out. All you need to do is to copy the desired php file in your parent theme and add it to your child theme. Be sure to stick to the parent theme structure. For example, if the php file is located in the parent theme folder, do not add it to a child subfolder.
Hope this helps.

I've already read it. This is for AliDropship Woo themes.

It does NOT work for AliDropship Original Plugin.
 

chris37

Well-Known Member
I've already read it. This is for AliDropship Woo themes.

It does NOT work for AliDropship Original Plugin.
Is not matter what plugin you use... the child theme creation is the same way allways.

Is also explain to you how to make it manual.
 

ThiagoN

New Member
Here is the problem:

El Greco theme (AliDropship original plugin) stores ALL theme settings, including scripts and styles (not recommended), in the database.

Capture.PNG

So the best and fastest (but not ideal) solution I found is copying the option values from the parent theme to the child theme.

You can do it manually, opening your database, or using the function below I've created.

PHP:
/**
* COPY PARENT THEME SETTINGS
*
* Beware!
* The parente theme settings will be copied to child settings
* every time you activate the child theme.
* If you want to copy the parent theme settings only once,
* delete this code after you child theme is ready.
*
*/
function child_copy_parent_theme_options() {  
    wp_cache_delete('alloptions', 'options');
   
    $wp_theme = wp_get_theme();
    $child_name = $wp_theme->Name;
    $parent_name = $wp_theme->parent()->Name;
    $child_slug = get_stylesheet();
    $parent_slug = get_template();

    // get parent theme options
    $parent_options = get_option("cz_{$parent_name}");
    $parent_mods = get_option("theme_mods_{$parent_slug}");

    // update child theme options
    update_option("cz_{$child_name}", $parent_options);
    update_option("theme_mods_{$child_slug}", $parent_mods);
}
add_action('after_switch_theme', 'child_copy_parent_theme_options');

Put it on your child theme functions.php file, and activate your child theme. It will automatically copy all parent theme settings and styles to your child theme.

(As usual, take precautions to ensure that your website files and database are safeguarded. Make a backup before any changes are applied.)

Bear in mind any changes to your child theme settings are NOT replicated automatically to your parent theme. Parent and child theme settings and styles are NOT synchronized.

If you want to deactivate your child theme in the future, you will probably need to copy the settings back to your parent theme.

If you wish to test another child theme, you will probably need to modify the code above to copy the settings and styles from one child theme to another.

Why do I need all this hard work to create a child theme?

Truth, you wouldn't need it, but the "El Greco" theme for AliDropship original plugin (I don't know about other themes) does NOT provide the right facilities to create a child theme.

ALL theme settings (including scripts and styles) are stored in the database, and this is not the best WordPress practice.

First, child themes won't be able to enqueue scripts and styles as usual.

Second, as WordPress loads all options on every page load by default, if the data in autoloaded options is considerably large, it will slow down autoload and consume as much memory.

Final consideration

As a premium theme, it surprises me El Greco is NOT "child theme friendly".

I hope the AliDropship team take advantage of my contribution and, at least, publish documentation about creating child themes for El Greco and other AliDropship original themes, if necessary.


PS: If anyone needs it, here is the child theme style.css file (as simple as possible).

CSS:
/*
    Theme Name: Your Child Theme Name
    Template: el-greco
*/
 

ThiagoN

New Member
Also, here is the code if anyone needs to change the permalink page.

I'm replacing "about-us" with "sobre-nos".

PHP:
<?php
    include(get_template_directory() . '/page-about-us.php');
?>

Put this file ("page-sobre-nos.php" in my case) into your child theme root directory.

Then, go to your WordPress admin and change your page slug.

Capture2.PNG

Enjoy! ;)
 
Top