WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP against HTML? thuh (16 posts)

  1. Qjoobsian
    Member
    Posted 1 year ago #

    So, from what I understand so far is that .php coding cannot be copied into a childs style.css without the risk of a crashed website once updates of the theme are installed.

    However, many options that one would like to add to the childs style.css to customize the website just a bit more are in the .php files. (footer, header etc.)

    Is there a way to work around this for WP newbies?

  2. Qjoobsian
    Member
    Posted 1 year ago #

    read initial post first.

    Maybe I can help myself a bit here...
    I suppose, one could copy the ENTIRE .php (for example header.php) coding into a childs theme and do the editing there?
    Or does this big bunch of codin make the website slow?

  3. esmi
    Forum Moderator
    Posted 1 year ago #

    .php coding cannot be copied into a childs style.css

    Generally speaking, PHP doesn't belong in a CSS file full stop. This holds for all web sites - not just those generated by WordPress. But you can add customised copies of any of the parent's .php template file to your child theme's folder. These child templates will always be used in preference to the parent's copies.

    Does that help clarify things?

  4. .php coding cannot be copied into a childs style.css

    That's correct. The style.css file is just plain text, no PHP inside of it.

    However, many options that one would like to add

    What are you trying to add? The child theme can have it's own functions.php file (not a copy of the parent theme's functions.php file). That's a good place to add your own functions.

    If you want to modify something in the parent theme's header.php or footer.php file then that's fine too. Just copy that file into your child theme's directory and make edits there.

    Edit: Aaand Esmi beat me to it again. Think I'll go peruse the No Replies section. ;)

  5. Qjoobsian
    Member
    Posted 1 year ago #

    Thx @esmi and Jan. You need to speed up Jan ;0)

    @esmi, it's what I thought but I don't understand why IT IS possible to take parts of a .php anyway. In fact that's the same as grabbing style.css code from the original and paste and edit into the Child theme right?

    @Jan, I like to keep things as simple as possible, just customize/personalize some small things so I am not sure if I should use a child theme based functions.php (I am not a coding star)

    @both
    Despite the fact .php does not belong in a style.css I can obviously take parts of a php to paste and edit in my childs style.css. Right?
    So, can I copy parts from the footer.php, paste into the childs style.css and edit it in a way so the website shows "powered by me"?

    Go go go Jan..;0)

  6. Andrew
    Forum Moderator
    Posted 1 year ago #

    Despite the fact .php does not belong in a style.css I can obviously take parts of a php to paste and edit in my childs style.css. Right?

    .css files only read CSS. There are no exceptions.
    .css files cannot read PHP.

  7. esmi
    Forum Moderator
    Posted 1 year ago #

    I can obviously take parts of a php to paste and edit in my childs style.css. Right?

    No. As Andrew said, that's just never going to work. To change your footer text, you need to copy footer.php into your child theme and then edit the child's version of that file to adjust the display.

    There are no exceptions.

    There are. Well... sort of. You can create (for example) a file called my-css.php, incorporate PHP conditionals/code to generate different CSS and then serve the whole thing up as text/css. But that's way ahead of (and quite different to) what Qjoobsian is asking about.

  8. Qjoobsian
    Member
    Posted 1 year ago #

    Thx @Andrew and Esmi. Where's Jan?

    @esmi
    Your my-css option is way out of my knowledge. Thx anyway.

    You keep saying that it is possible to copy .php files into a child theme.
    I read that as > into child theme style.css, maybe that's where my confusion starts because css files cannot read php?!.

    Could you give me a step-by-step method? Let's take the footer as an example.
    Thx in advance for ur help.

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    I read that as > into child theme style.css

    No. You can also create custom template files in your child's theme folder. Make a copy of footer.php and drop the new copy into your child theme's folder. Now edit the child's copy. Using Twenty Twelve's footer.hp file as an example, it contains the line:

    <a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentytwelve' ) ); ?>" title="<?php esc_attr_e( 'Semantic Personal Publishing Platform', 'twentytwelve' ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentytwelve' ), 'WordPress' ); ?></a>

    which you could change to something like:

    <a href="<?php echo esc_url( home_url( '/' ) ); ?>">Powered by Qjoobsian</a>
  10. Andrew
    Forum Moderator
    Posted 1 year ago #

    Jan's taking a tea-break, he's been working hard this Christmas at the WordPress.org forums.

    Qjoobsian, are you using a particular theme you need help with?

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    Based on other topics, I'm guessing Twenty Twelve.

  12. Qjoobsian
    Member
    Posted 1 year ago #

    Yep, indeed. Twenty Twelve Theme, Andrew.

    @esmi. Something just hit me :0) Till now I only edited style.css.
    It got stuck in my brain.
    Ofcourse you mean: drop an edited copy named footer.php into the childs theme FOLDER (by using ftp)
    This way it overwrites the twenty twelve theme footer.php. Right?
    So this should work for all other .php stuff too.

    Your code worked, now I only need to find out how to link it to Qjoobsian.com. I guess something in this line needs to be changed.

    Sorry for my hard understanding, my Dutch is much better.

  13. esmi
    Forum Moderator
    Posted 1 year ago #

    Right?

    Spot On! :-)

  14. Qjoobsian
    Member
    Posted 1 year ago #

    Pfff.
    I cannot find out how to link Powered by Qjoobsian to an alternative website addres, opening in a new frame.
    It keeps referring to the home of the website its on.

    Which one of the code needs to be changed?

  15. esmi
    Forum Moderator
    Posted 1 year ago #

    Try:

    <a href="http://some_domain">Powered by Qjoobsian</a>

  16. Qjoobsian
    Member
    Posted 1 year ago #

    Wauw, works.
    I admire you...

    Out of interest, why is this code so simple and short.
    I saw bunches of other ones (that did not work for me) but were much longer. They probably were not hyperlinked entirely or something...

    Thx a million

Topic Closed

This topic has been closed to new replies.

About this Topic