Showing posts with label How to create WordPress theme with Bootstrap. Show all posts
Showing posts with label How to create WordPress theme with Bootstrap. Show all posts

Friday, 6 May 2016

Customizing or styling blog page on WordPress

Previous Tutorial : http://1wmedia.blogspot.in/2016/05/creating-default-blog-page-homephp-and.html


In this lesson, we will learn how to style default Blog page in WordPress. Please view my previous tutorials for creating blog page.

1. First go to you theme folder, open home.php file.
2. Here you can modify your blog page.
3. In our tutorial, Just remove the codes (fully) and add  the following code. or you can refer the video for particular edits.



<?php get_header(); ?>


    <!-- Carousel
    ================================================== -->
    <div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
    
      <div class="carousel-inner" role="listbox">
        <div class="item active">
          <img class="first-slide" src="<?php bloginfo('template_directory'); ?>/images/avoid when blogging.jpg" alt="First slide">
         
        </div>
       
      
      </div>
     
    </div><!-- /.carousel -->


    <!-- Marketing messaging and featurettes
    ================================================== -->
    <!-- Wrap the rest of the page in another container to center all the content. -->

    <div class="container marketing">

      <!-- Three columns of text below the carousel -->
      <div class="row">
     
         <h1 align="center"><?php wp_title('');  ?></h1>
     
      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
      <div class="container text-center">
<h1><a href="<?php the_permalink(); ?>"><?php the_title();  ?></a>  </h1>
<p><?php the_author(); ?></p>



     
  
                            <p><?php the_excerpt(); ?></p>
                            <p><a href="<?php the_permalink(); ?>">Read More...</a> <hr /></p>
                       
                       
   

              <?php endwhile; else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

</div>
          
      </div><!-- /.row -->

      <hr class="featurette-divider">


     <?php get_footer(); ?>



4. Save the home.php with new code or edited codes.

5. In this tutorial we have added/modified the following:

For Page or BLOG title:

<h1 align="center"><?php wp_title('');  ?></h1>

 Giving link to the single post (But single post not work now. But link will work. We will add single.php file later for single post view):

<h1><a href="<?php the_permalink(); ?>"><?php the_title();  ?></a>  </h1>


Display Author Name:

<p><?php the_author(); ?></p> 


Change the_content(); function into the_excerpt(); and added Read more text by following code:

  <p><?php the_excerpt(); ?></p>
                            <p><a href="<?php the_permalink(); ?>">Read More...</a> <hr /></p>


One closing div changed (refer video).

Video Tutorial of this post:















Thursday, 24 March 2016

How to create a Bootstrap WordPress Theme dynamic submenu - Step 7

In this tutorial, we will learn how to add sub menu. Previous tutorial -> http://1wmedia.blogspot.in/2016/03/how-to-create-bootstrap-wordpress-theme_15.html


1. First click the following link and get all the code you want -> https://gist.github.com/setola/3765640

2. Add the functions.php code from Extended Walker and add it to your functions.php file and save it.

3. open your header.php.

4. Add depth value and call wp nav walker inside the $args array. (please refer the video)

'depth' => 0,
 'walker' => new BootstrapNavMenuWalker()

and hit save.

5. Now open the style.css and add the following code and save the file.

/* dropdown */
.dropdown-menu {
    margin: 0px auto;
}
.dropdown-menu .dropdown-menu {
    left: 100%;
    top: 0px;
}
/*  shows the dropdown on hover*/
.navbar ul.nav li:hover > ul.dropdown-menu {
    display: block;  
}
/* before and after */
.navbar .nav > li > .dropdown-menu::before, .navbar .nav > li > .dropdown-menu::after {
    display: none;
}



6. Now get the Javascript code (open-on-mouseover.js ) from this link -> https://gist.github.com/setola/3765640

7. Create a Javascript  file with name(for example extra_js.js) , Put the code and save it inside the js folder in the themes folder.

8. Now call or enqueue the Js file with following code at functions.php .It should ne inside the function newsite_js() (Please refer the video)

wp_enqueue_script( 'extra_js', get_template_directory_uri() . '/js/extra_js.js', array('jquery'), 'booostrap.min.js', '' );

9. Now move to appearance -> menus on the Dashboard -> Add submenus -> Now all submenus will work properly.

10. That's all.

Video Tutorial:








 


Friday, 11 March 2016

How to create a Bootstrap WordPress Theme? - step 4

If you didn't read the third step, then click here. Ok. Now we will move to the third step.

1. In this step, first create the Js files for the theme from the demo.
Save the file at js folder which is available at your themes folder. or create the new one and save them with source code

2. Remaining Js files - Direct linking url -> you need not to save this -> we will do this at functions.php

3. Add the following code into functions.php file, Just before the " ?> " .I mean before the PHP closing tag.

function newsite_js() {

    global $wp_scripts;

    wp_register_script( 'html5_shiv', 'https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js', '', '', false );
    wp_register_script( 'respond_js', 'https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js', '', '', false );

    $wp_scripts->add_data( 'html5_shiv', 'conditional', 'lt IE 9' );
    $wp_scripts->add_data( 'respond_js', 'conditional', 'lt IE 9' );
   
    wp_enqueue_script( 'IE_emeulationmode_js', get_template_directory_uri() . '/js/ie-emulation-modes-warning.js', array('jquery'), '', false );
   
    wp_enqueue_script( 'Google_ajax_js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', '', '', true );
   
    wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
   
   
    wp_enqueue_script( 'holder_js', get_template_directory_uri() . '/js/holder.min.js', array('jquery'), '', true );
    wp_enqueue_script( 'IE10_js', get_template_directory_uri() . '/js/ie10-viewport-bug-workaround.js', array('jquery'), '', true );

}
add_action( 'wp_enqueue_scripts', 'newsite_js' );

4. Now save the functions.php file

5. Download the Bootstrap from the following link.

http://getbootstrap.com/getting-started/#download

6. Extract the Bootstrap file, find "fonts" folder. Copy the "fonts" folder and paste into the theme folder.

7. Now our scripts are activated.

8. You can verify - By your slider moving and menu working.

Video Tutorial:



Monday, 7 March 2016

How to create a Bootstrap WordPress Theme? - step 3

If you didn't read the second step, then click here. Ok. Now we will move to the third step.

1. Create two new folders at your themes folder namely css,js.

2. In css folder, create css files namely bootstrap.min.css and ie10-viewport-bug-workaround.css.

3. Click the following link," view-source:http://getbootstrap.com/dist/css/bootstrap.min.css " copy and paste the code at bootstrap.min.css

4. Click the following link, "view-source:http://getbootstrap.com/assets/css/ie10-viewport-bug-workaround.css " copy and paste the code at ie10-viewport-bug-workaround.css file.  Save both files.

5. Now click and open js folder. Create js file named ie-emulation-modes-warning.js

6. Click the following link, "view-source:http://getbootstrap.com/assets/js/ie-emulation-modes-warning.js " copy and paste the code into ie-emulation-modes-warning.js, Save the file.

7. Now add the following code at header.php file just before the "</head>" tag

<?php wp_head(); ?> .  Save header.php file.

8. Then open the footer.php file, add the following code just before the "</body>" tag

<?php wp_footer(); ?> . Save footer.php file.

9. Create a new file at your theme folder, named functions.php. then add the following code into the file, Save it.

<?php

function newsite_styles() {

wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'Ie_css', get_template_directory_uri() . '/css/ie10-viewport-bug-workaround.css' );


}
add_action( 'wp_enqueue_scripts', 'newsite_styles' );

?>


10. Open the style.css file and add the following code.

view-source:http://getbootstrap.com/examples/carousel/carousel.css

Do not delete the above comment line on the style.css. Add the code below the comment line. And save it.

11. Now view the site. Some styles are added. But we have added styles and scripts for header only. We will do footer styles and scripts in next lesson.


Video tutorial: