• I’m working on Tesseract theme (child-theme). I found on internet some code and downloaded it. It’s a folder which includes inside an index.html, a style.css (the index.html file is reffering to that css file (<link rel=”stylesheet” href=”style.css” />) and a folder with name IMG which includes some images. This html file is an image slider. It works very fine as a stand-alone web page. I searched a lot on internet how could I put this image slider only on my home page of my child-theme website as a background image slider but didn’t get a clear answer. Could anyone give me a hand?

    (The index.html file inside has got some javascript code with many functions)

    I like this method much more than installing some plug-in image slider, even so I didn’t find an image slider plug-in that makes the job a I want (put the image slider only to my home page-if you know some good plug-in please let me know…)

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter danis_gr

    (@danis_gr)

    Any help please?

    jack randall

    (@theotherlebowski)

    just use a slider plugin instead of trying to force some random piece of code you’ve found on the internet into your site.

    Thread Starter danis_gr

    (@danis_gr)

    It’s not so random and I am a little bit familiar with html…so why not to try and learn more things instead of doing easy and routine things such as downloading an image slider plug-in????

    If anyone want to help me, they are welcome.

    jack randall

    (@theotherlebowski)

    well, if you want to put it in your site then that’s up to you. you’ll have to figure out how your theme is serving up content and template files in order to work out exactly where to put the html that creates the slideshow, the css will go into your style.css file and the javascript that activates it will have to end up in the footer of the site just before the body tag.

    create a new file and call it something like slideshow_x.js and add in the javascript code. then in the theme’s functions.php file you’ll need to register this script and then enqueue it in order for wordpress to process it correctly (as far as i know).

    i’m all for learning new stuff just i learned the hard way not to trust chunks of code from the internet that do fun things, especially when they’re not written to degrade gracefully or play well with something like wordpress.

    Thread Starter danis_gr

    (@danis_gr)

    I really understand your thought about getting a piece of code from the net. The thing I would like to get to know is just the process (I just gave an example of the “prepared” code. Just to know the way you put a code on WordPress.

    So in our issue:

    “the css will go into your style.css file”:
    you mean to open my “ready” css file take the code and put it in the “original” style.css file of my theme

    “create a new file and call it something like slideshow_x.js and add in the javascript code”:
    you mean to remove the javascript snippet code <script type=”text/javascript”>…..</script> from the html file and paste it to the new slideshow_x.js file.

    “then in the theme’s functions.php file you’ll need to register this script”:
    what you mean here by saying “register”?

    “then enqueue it in order for wordpress to process it correctly”:
    I understand a little bit, not so much because I am confused of many things I read via googling. πŸ™

    And something more: alla these files are going to be found on the “theme” folder? the IMG folder inside “theme” folder too?

    jack randall

    (@theotherlebowski)

    don’t try this on a live site, set yourself up a development server if you haven’t already (XAMPP for PC or MAMP for Mac)!

    – if you copy the css from the slideshow that you’ve grabbed from the net and paste it into the theme’s style.css file (doesn’t matter where but maybe put /* slideshow css */ before it to separate it out from the rest of the theme’s css) and save the file. or create a completely new stylesheet called slideshow_x.css and put it in there so it’s totally separate.

    – next, take the javascript that makes the slideshow work and put that in a file called slideshow_x.js and save that to your theme folder too. your theme may have a folder for .js files, if it does put it in there.

    – next comes a harder part. depending on which theme you’re using it will handle template files in a different way. it may just load files like page.php and single.php and that’s it or it may load page.php and call into page.php a sub template file like content-home.php for the home page contents, content-contact.php for a contact form etc.

    – *** in the theme i created for a site that used a bootstrap carousel i had to create a new page template (page-home.php) and in that use the get_template_part(‘content’, ‘home’); method to call the part with the carousel into the page-home.php template file. it’s layers within layers! ***

    – once you’ve found where the html for the carousel is supposed to go in the theme’s template structure paste it in and we’ll come back to it so that it calls the images required.

    – put your images into the theme’s images folder.

    – in the theme’s functions.php file you need to register and then call the scripts, both css and javascript. here’s a really good article explaining how to do that: http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/. it’s not as complex as it may seem and it’s the way that wordpress likes things added to it.

    – in the html for the slider you’ve probably got some <img src=”…” /> tags linking to the images. you need to tweak these so that wordpress knows where to find the images now they’re in the theme and not where they were. for this use:

    <img src="<?php bloginfo('template_directory'); ?>/folder/image-name"/>

    so, if you’ve pasted the html into the right template file and tweaked the image src=”” to reflect the template directory, registered and enqueued the css and javascript correctly, uploaded your images to the theme’s images folder it should work…

    if it doesn’t keep playing about with it, moving things about until it does. but as mentioned at the top of this, if you haven’t already, set up a development server on your own computer to try this out, your site visitors don’t need to see this πŸ˜€

    Thread Starter danis_gr

    (@danis_gr)

    OOOohhh thank u very much!!! In the afternoon I will try to make all these steps and I’ll let you know.

    Thank u again!

    Thread Starter danis_gr

    (@danis_gr)

    Up to see all these things, I wanna reffer to your first point where u r talking about XAMPP. I installed xampp (D://xampp) and inside installed the wordpress (D://xampp/wordpress) but AFTER installing “normally” the wordpress and creating my website (Tesseract child-theme) (I had no idea up to then about xampp)

    Can I NOW transfer my website and make changes on it on the localhost of xampp? Do I have to copy-paste some files of my existed website? which of all????

    Something noticeable: I created a database “wordpress database” because needed for xampp (phpMyAdmin). This is the db for my the suppossed new website I think so at least, isn’t it?

    But also I noticed after created my website “normally” (didn’t know about xampp then) before some days in cPanel—>phpMyAdmin there is a database with the name “danis_wrdp1”. That means that if I transfer my existed site to my xampp localhost, a database called “danis_wrdp1” will automatically be transferred there too?

    Thread Starter danis_gr

    (@danis_gr)

    About my above questions I realized that: no, it doesn’t need to have the 2 databases the same name, just the same content except of all “mydomainname.com” which should be replaced by localhost/thenameofthefolderinsidehtdocs” inside the database sql file. If I am wrong please correct me. After that replacement I upload this file in the localhost phpMyAdmin for creating the database.

    Even so, I could not make it manually by myself..something was going wrong.

    I finally found solution on working on localhost via the plugin Duplicator by “LifeInTheGrid” !!! It also gives you the chance to keep the installer and archive files as a backup for your live server’s website. This video helped me a lot:
    https://www.youtube.com/watch?v=_tm088gNreY

    So now I am going to continue from where I started asking you about the image slider… Jack, I will follow what u said and in a few days I will reply about it.

    jack randall

    (@theotherlebowski)

    you’re almost there, you’ll need to edit the wp-config file from the live site when you put it on the localhost on your computer, it will have the database/server details from the live host so you’ll need to give it the localhost details so it can find the local database.

    keep going, you’re doing well πŸ˜€

    Thread Starter danis_gr

    (@danis_gr)

    I will try to do what u say just I have first to read a lot… πŸ™‚

    May I insert the hmtl code including js in the html editor of the page?
    How could I do something like that? I mean ok I insert the code..but after?
    What do I do? Where is this code belong to? (folder?) so I could link the images of the slider to it?

    Is there any good and easy plugin for that?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Html/CSS code to WordPress’ is closed to new replies.