how to override wordpress parent theme theme options in child theme - php

I want to override the parent theme option in child theme, so how can I do this in using code inside my child theme.
My problem is this,
I have use the ready-made word-press theme now, I want the some new options in theme options using my child theme so is there any way to override theme options.
I have also include my theme optional file like below:
include (CHILD_DIR.'admin/theme-options-dependency.php');
Thanks in advance.

First of let me know which theme you have used. In theme you don't need to override theme option just check parent theme option code you have find lots of action and filter when theme option register. You just use that filter & action and add your extra option with filter.

Related

wordpress child theme does not automatically load single-post_type.php from parent

For the first time I am trying to setup a wordpress child theme. The parent has a complicated templates for custom post types and header.php and footer besides stylesheets and javascript files etc.
The child theme only needs to change the css (for now). My child theme only has style.css and functions.php.
I already have a single-product.php for a custom post type product in the parent theme folder. That is not getting loaded automatically from the parent. Please suggest what is required to get this working.
Thanks.
Not really the best solution but can help.
Copy header.php into the child theme and put your css in the <head> section. Remember to enclose your css with <style>custom-css{...}</style>

Child theme doesn't read template part file

I'm building my first child theme. My child theme is my active theme at the moment. So, I have a file under the parent theme which is at wp-content/themes/mytheme/template-parts/ajax-mytick-list.php and I copied it to wp-content/themes/mytheme-child/template-parts/ajax-mytick-list.php and edit it there. But the site is not showing the one that I edited under child theme. Cos if I edit the same file in parent theme, the result is reflected.
What am I doing wrong?
You can override page templates this way, but not other files. In this case, you'll need to override the according function (guide) or hook into it with an action hook or filter.
More details according to your question below:
You'll need to find out where the template-parts file is getting included. Search the parent theme for something like
require get_template_directory() . '/template-parts/ajax-mytick-list.php';
If that call is in a template file, copy it to your child theme and change the call to
require get_stylesheet_directory() . '/template-parts/ajax-mytick-list.php';
If it's not in a page template, you'll need to dig deeper, but as every theme is different, it's impossible to say how exactly you'll get there.

How can i include a template from the parent theme in the current theme in Magento 2?

I'm using Magento ver. 2.1.8. I created a new theme and inherited the purchased theme. In the parent theme i have a template that i override in the child theme. How can i include the template from the parent theme in the current theme? I think that my decision is not optimal, but i think it's a dirty solution to copy all template HTML from the parent theme.
My solution is:
$templateFile = str_replace('my-theme-vendor/my-theme', 'parent_theme_vendor/parent_theme', $block->getTemplateFile());
include($templateFile);
Just simply add it to you theme by copying it.
Foo/Bar is child theme. Its parent is Precious/Theme
copy
Precious/Theme/Magento_Catalog/templates/product/list.phtml
to
Foo/Bar/Magento_Catalog/templates/product/list.phtml
An you have your template ready to be edited. This is a cleanest way to override your parent theme template.

WordPress Child Theme - General Understanding

I am trying to understand how to use a Child Theme in wordpress.
I am afraid that something will go wrong in the process of developpment because I haven't completely understood how to use the child theme or its integration wasn't done properly.
My confusion comes after I create the child theme and by adding the style.css and functions.php.
At this point, can I make any changes that I want to the child theme and it will still work?
For example,
After I modify the front-end of the website with the use of the child theme, I want to add some forms that will insert data into the database.
Do I have to implement any php files from the parent-theme in order to make this work ?
Or do I treat my child-theme as a fresh theme (blank canvas) and code the back-end however I would like ?
Thanks
Think of the child theme as a layer on top of the parent theme. By default (if you add nothing to the child theme other than a style.css file), all the templates from the parent theme will be used. The only thing you have to have is the style.css file. If you wanted to override the page.php template for instance, you would simply just make a page.php file in your child directory and WordPress will use that template instead of the parent template. Same goes for any template file or template part.
You can have a functions.php file in your child theme and it will be included in addition to the parent functions file.
Usually the parent's style.css file would be enqueued before the child's style.css file, but it depends on how those files get enqueued. The system is quite flexible.
Your child theme is not a blank canvas. It inherits style.css, functions.php and all the post/page templates from the parent theme. The style.css file of your child theme will load after that of the parent theme, thus enabling you to add more CSS rules. The functions.php file of your child theme will load before the parent's functions.php file.
The child also inherits all the templates from the parent. However, if a template exists in the parent and you create it in the child the child theme's template will completely override the parent's template. For more information on parent-child theme relationship I highly recommend that you check the official child themes documentation.

Extending Theme Options to Child Themes in Wordpress

I have purchased the Honest theme. I have also created a child theme for some look/feel changes. In my child theme I have also created an additional custom post-type.
For some reason the Honest theme options are not available in my child theme dashboard. Since I have a custom post-type I don't want to simply use the parent theme because any updates will overwrite my custom post-type.
Is there a way to make the parent theme options available in a child theme? If so, can you point me toward a direction of that solution?
Hard to say without seeing the actual source code.
If you're willing to use the parent theme, you can put the code that registers the custom post type in a plugin of your own. Must-use plugins are great for this: http://codex.wordpress.org/Must_Use_Plugins
You can also put your style mods there, e.g. enqueue an extra stylesheet that overrides the styles from the parent theme: http://codex.wordpress.org/Function_Reference/wp_enqueue_style

Categories