creating a child theme and modifying ie. header.php Hi

creating a child theme and modifying ie. header.php

Hi dear,
I am just creating my first child theme. Please can you help me to understand better the following?

1. Style.css: I have created this new file in the child theme directory with only my part of customizing code part. Before I was adding this code to the "edit CSS" for my theme. Now I can copy those code in the child style.css? correct?

2. functions.php: created this file enqueueing the parent and child theme stylesheets only. Nothing else!

3. But what if I want to edit ie. the header.php?
I need to copy the full file from parent theme and add my customizing code or simply create a new empty file header.php in the child theme and add only my customizing code?

Thank you so much for your help.
Have a nice day.
Paddy

  • Karolina
    • The Bug Hunter

    Hi @Paddy,

    1) yes.
    2) nothing else is necessary, but if you need to add some functions, you can
    3) you should copy original header.php and change whatever you want in your child-theme (original will be overridden)

    Have a great day!
    Karolina

  • Paddy
    • The Bug Hunter

    Thanks Karolina,

    Sorry another question:
    What If I am customizing some marketpress files or other plugins in general?
    Should I add those mp files also in the child theme? Just to avoid to delete the customizing code if mp is updated?

    Thanks.
    Paddy

  • Kasia Swiderska
    • Support nomad

    Hello Paddy,

    What If I am customizing some marketpress files or other plugins in general?

    That depends of the files you are editing. If plugin has the theme templates files, then you can use them in your child theme.

    E.g. to create a custom product page:

    1. Make a copy of the page.php template file in your theme directory and rename it mp_product.php
    2. mp_product.php must use the mp_* functions instead of the_content(), see template-functions.php for a list of functions relevant to products.

    More about creating custom templates in MarketPress you will find in the marketpress/ui/themes/Theming_MarketPress.txt file

    But this only applies for the template files, not the core files in the plugins. In some cases there are actions and filters, that can override the core function of plugin, and you can use them in your functions.php file.
    If this is possible with action/filter, you will get code for this from staff members.

    Kind regards,
    Kasia

  • Paddy
    • The Bug Hunter

    Sorry Kasia,
    I am not so advanced to understand what you wrote me. Sorry my bad!
    What is a template file? do you mean theme files? Core files are the wp files?
    How do I know if a plugin has a theme template file?

    for the custome product page:
    page.php is a theme page? or mp page? or core page?
    Why should I rename it? Shouldn't have the same name so the system can recognized it?
    what are the following:
    mp_*?
    the_content()?
    you will get code for this from staff members.?

    Sorry about all those questions but otherwise I can't follow your discussion.

    Thanks
    Paddy

  • Karolina
    • The Bug Hunter

    Hi @Paddy,

    a template file is file used for displaying some content of the plugin/theme (typicaly, page, product etc.)

    mp* files are market press files, you should have a look on the link from @Kasia "marketpress/ui/themes/Theming_MarketPress.txt file"

    you will get code for this from staff members.?

    That means if you express the need here, somebody will try to help you here, because it looks like you don't know much about WP coding.

  • Paddy
    • The Bug Hunter

    Hi Karolina,
    I have now all these problems because i am starting using mp paid version to have more functionality.
    The real problem is that i was happy with the free mp version.

    For the solution above i was asking what does it mean mp* within the solution suggested.

    Please read above?

    Thx
    Paddy

  • Rupok
    • Support Ninja

    Hi Paddy

    I hope you had a wonderful day.

    # page.php is a theme page? or mp page? or core page?
    >> Theme Page.

    # Why should I rename it? Shouldn't have the same name so the system can recognized it?
    >> You should *make a copy* of the page.php template file in your theme directory first. Then rename the copied file to "mp_product.php".

    # what are the following:
    # mp_*?
    >> * sign indicates anything which is unknown. For example, marketpress functions are like mp_product_price(), mp_product_link() etc. Notice that every function starts with "mp_". So mp_* means any function of Marketpress which start with "mp_". If you are good in programming, then you can find all the functions inside "template-functions.php" file located here " wp-content/plugins/marketpress/includes/common/" directory.

    # the_content()?
    >> the_content(); displays the contents of the current post. You can get more idea on this here: https://codex.wordpress.org/Function_Reference/the_content

    Please let us know if you have any further confusion. We will be glad to help.

    Have a nice day. Cheers!
    Rupok

  • Paddy
    • The Bug Hunter

    Hi Rupok,

    Thank you very much for your explanation.

    The page.php was used by Kasia I think as an example.
    My general question was more related to the adjustment needed in order to show the 'full' product picture on this file: /wp-content/plugins/marketpress/includes/common/template-functions.php

    Let me copy here the indication of a previous post:
    "You can set image size for products in Store Settings -> Presentation -> Product Page Settings -> Image size, where you can choose from non cropped images sizes or choose custom size.
    If you want to change this in the plugin code, you can do that in the /wp-content/plugins/marketpress/includes/common/template-functions.php file in line 2397 and change this line
    $img_url = mp_resize_image( $value, $original_image[0], $size );
    to this
    $img_url = mp_resize_image( $value, $original_image[0], 'full' );
    Kind regards,
    Kasia
    https://premium.wpmudev.org/forums/topic/product-image-cropped-not-shown-enterily#post-992986 "

    So far I understood that it is too complicate to have it done manually.
    I do think that there should be an option in mp settings to show the picture in full.

    Could this be a Next feature request?

    Thanks.
    Patrizio

  • Kasia Swiderska
    • Support nomad

    Hello Patrizio,

    I apologize for my previous confusing answer. But I hope Karolina & Rupok explained that better.

    I do think that there should be an option in mp settings to show the picture in full.

    Could this be a Next feature request?

    Yes, I can move this thread to Features & Feedback, so more members can show support for this idea.

    Please note, that when we can we do try to give solutions without changing code of the plugins - but sometimes its not possible, and that is why here was this proposed.

    kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.