Skip to content

Instantly share code, notes, and snippets.

@RishniMeemeduma
Last active January 12, 2018 05:29
Show Gist options
  • Save RishniMeemeduma/a42a5971de6cb1bd8538a583412ac02a to your computer and use it in GitHub Desktop.
Save RishniMeemeduma/a42a5971de6cb1bd8538a583412ac02a to your computer and use it in GitHub Desktop.
Html to wordpress
<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="box-layer custom-padding">
<section>
<h3> Oh Snap! Page not found!</h3>
<h3> It seems you're looking for something that isn't here!</h3>
<a href="<?php echo home_url(); ?>">Click here</a> to go back to homepage!
</section>
</div>
</div>
<aside>
<!-- SIDEBAR AREA -->
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?> </div>
</aside>
</section>
<?php get_footer(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( sprintf( '
<h1 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>
' ); ?>
<?php if ( 'post' == get_post_type() ) : ?>
<div class="entry-meta">
<?php endif; ?>
</header>
By <a href="<?php the_author_posts() ?>"><?php the_author(); ?> </a> / On <?php echo get_the_date('F j, Y'); ?> / <?php the_category(); ?>
<?php the_excerpt(); ?>
</div>
<?php
/*********** Define constants *************/
define('THEMEDIR',get_stylesheet_directory_uri());
define('IMG',THEMEDIR.'/images');
/************* Add menu ************/
add_action('init','register_my_menus');
function register_my_menus(){
register_nav_menus(array('main-menu' =>'Main Menu' ));
}
/*************** Register sidebar ******************/
register_sidebar(array(
'id' => 'main-sidebar',
'name' =>__('Main Sidebar',$text_domain),
'description' => __('This is the main sidebar',$text_domain),
));
/************* add theme support for post thumbnails ********************/
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails');
set_post_thumbnail_size(742,428);
}
/******************** Remove the brackets in excerpt *******************************/
function trim_excerpt($text){
$text =str_replace('[hellip;]', '...', $text);
return $text;
}
/********************************** Comment ***************************************/
if( get_option('thread_comments') ){
wp_enqueue_script('comment-reply');
}
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!--> <html <?php language_attributes(); ?>> <!--<![endif]-->
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<title><?php wp_title('|', true, 'right');?><?php bloginfo('name');?></title>
<meta name="description" content="<?php bloginfo('description'); ?>">
<meta name="author" content="Sam Norton">
<!-- Mobile Specific Meta -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- Stylesheets -->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('template_url') ?>/css/bootstrap.css" />
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/style.css" />
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<?php if( is_page('contact') ){ ?>
<script type=&"text/javascript&" src=&"<?php bloginfo('template_directory'); ?>/js/jquery.validate.min.js&"></script>
<script type=&"text/javascript&" src=&"<?php bloginfo('template_directory'); ?>/js/verif.js&"></script>
<?php }?>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<!-- HEADER -->
<header class="main-header align-center ">
<a href="<?php echo home_url(); ?>" class="logo" ><img src="<?php print IMG;?>/logo.png" class="img-responsive" alt="<?php bloginfo('name');?>" /></a>
<nav class="main-nav">
<?php wp_nav_menu(array( 'theme_location' => 'main-menu',
'container' => '',
'menu_class' => 'inline'
));
?>
</nav>
</header>
<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
<?php if (have_posts()) : ?>
<div class="row">
<div class="col-md-8">
<ul class="negative-margin">
<li>
<?php while(have_posts()) : the_post(); ?>
<h1><a href="<?php the_permalink(); ?>" class="gray"><?php the_title(); ?></a></h1>
By <a href="<?php the_author_posts() ?>"><?php the_author(); ?> </a> / On <?php echo get_the_date('F j, Y'); ?> / In <?php the_category(', '); ?>
<?php if (has_post_thumbnail()) : ?>
<figure> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('', array('class' => 'opacity-hover box-layer img-responsive')); ?></a>
</figure>
<?php the_excerpt(); ?>
<div class="btn-margin"> <a href="<?php the_permalink(); ?>" class="btn btn-primary">CONTINUE READING >>> </a> </div>
</li>
<?php endif; ?>
<?php endwhile; ?>
</ul>
<?php global $wp_query; if ($wp_query->max_num_pages > 1) : ?>
<div class="box-layer align-center page-nav">
<ul class="btn">
<li><?php previous_posts_link('<<< Previous Page', $wp_query->max_num_pages); ?></li>
<li><?php next_posts_link('Next Page >>>', $wp_query->max_num_pages); ?></li>
</ul>
</div>
<!-- end box -->
<?php endif; ?>
<?php endif; ?>
</div>
<aside>
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?>
</div>
</aside>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
<?php /* Template Name: About Page */ ?>
<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="box-layer custom-padding">
<img src="<?php print IMG; ?>/1.png" class="opacity-hover img-responsive center" alt="my image" />
<div class="align-center">
<h3>About Me</h3>
<b>I am a web designer and a front web developer with over 2 years of experience in the industry. Have a passion for designing detailed, creative and modern websites graphics. I spend most of my time practically every day, experimenting with HTML, CSS and WordPress.
</b>
<hr/>
<h3 class="blue">Feel free to contact me for some Web Projects</h3>
<i class="fa fa-envelope"></i> Email: [your email]
<i class="fa fa-twitter"></i> Twitter: [your twitter username]
</div>
</div>
<!-- END RELATED ARTICLE AREA -->
</div>
<!-- SIDEBAR AREA -->
<aside>
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?>
</div>
</aside>
</section>
<?php get_footer(); ?>
<?php /* Template Name: Page Contact */ ?>
<?php
if(isset($_POST['submitted'])) {
if(trim($_POST['contactName']) === '') {
$nameError = 'Please enter your name.';
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}
if(trim($_POST['email']) === '') {
$emailError = 'Please enter your email address.';
$hasError = true; } else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+.[a-z]{2,4}$/i", trim($_POST['email']))) {
$emailError = 'You entered an invalid email address.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(trim($_POST['subject']) === '') {
$subjectError = 'Please enter a subject.';
$hasError = true;
} else {
$subject = trim($_POST['subject']);
}
if(trim($_POST['comments']) === '') {
$commentError = 'Please enter a message.';
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
}
if(!isset($hasError)) {
$emailTo = get_option('tz_email');
if (!isset($emailTo) || ($emailTo == '') ){
$emailTo = get_option('admin_email');
}
$subject = '[PHP Snippets] From '.$name;
$body = "Name: $name nnEmail: $email nnComments: $comments";
$headers = 'From: '.$name.' <'.$emailTo.'>' . "rn" . 'Reply-To: ' . $email;
wp_mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
} ?>
<?php get_header(); ?>
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="box-layer custom-padding">
<div id="container">
<div id="content">
<div class="align-center">
<h3>We want to hear from you!</h3>
If you are seeking to contact us, please fill up the form below. If you want to advertise or be partner with us just inform us on the message box below.
Thank you so much for your support!
We really appreciate!
<div class="entry-content">
<?php if(isset($emailSent) $emailSent == true) { ?>
<div class="thanks">
Thanks, your email was sent successfully.
</div>
<?php } else { ?>
<?php the_content(); ?>
<?php if(isset($hasError) || isset($captchaError)) { ?>
Sorry, an error occured.
<?php } ?>
<form action="<?php the_permalink(); ?>" id="contactForm" method="post" class="general-form">
<div class="contactform">
<input type="text" name="contactName" class="form-control" id="contactName" placeholder="Your Name.." value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
<input type="text" name="email" id="email" class="form-control" placeholder="Your Email.." value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="required requiredField email" />
<?php if($emailError != '') { ?>
<span class="error"><?=$emailError;?></span>
<?php } ?>
<input type="text" name="subject" id="subject" class="form-control" placeholder="Your Subject.." value="<?php if(isset($_POST['subject'])) echo $_POST['subject'];?>" class="required requiredField subject" />
<?php if($subjectError != '') { ?>
<span class="error"><?=$subjectError;?></span>
<?php } ?>
<textarea name="comments" id="commentsText" class="form-control" placeholder="Your Message" rows="4" cols="100" class="required requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
<?php if($commentError != '') { ?>
<span class="error"><?=$commentError;?></span>
<?php } ?>
<input type="submit" class="btn btn-primary no-border" value="Send Message"></input>
</div>
<input type="hidden" name="submitted" id="submitted" value="true" />
</form>
<?php } ?>
</div>
<!-- .entry-content -->
</div>
<!-- .post -->
</div>
</div>
</div>
<!-- RELATED ARTICLE AREA -->
</div>
<aside>
<!-- SIDEBAR AREA -->
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?>
</div>
</aside>
</section>
<?php get_footer(); ?>
<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">s
<div class="row">
<div class="col-md-8">
<div class="box-layer custom-padding">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3> <?php the_title(); ?> </h3>
<?php if (has_post_thumbnail()) : ?>
<figure> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('', array('class' => 'opacity-hover box-layer img-responsive')); ?></a> </figure>
<?php endif; ?>
<?php the_content(); ?>
<?php endwhile; endif; //ends the loop ?>
</div>
</div>
<!-- SIDEBAR AREA -->
<aside>
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?>
</div>
</aside>
</section>
<?php get_footer(); ?>
<?php get_header(); ?>
<section>
<hr class="no-margin" />
<div class="blog-container section-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h3 class="page-title"><?php printf( __( 'Search Results for: %s', '_s' ), '
<h3>' . get_search_query() . '</h3>
' ); ?></h3>
</header>
<!-- .page-header -->
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php /*** Run the loop for the search to output the results. */ get_template_part( 'content', 'search' ); ?>
<?php endwhile; ?>
<?php else : ?>
<h3> No results found</h3>
<?php endif; ?>
</div>
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?>
</div>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
<div class="controller">
<form role="search" method="get" class="search-form" action="<?php echo home_url(); ?>">
<input type='textbox' name="s" class="form-control" id="search-box" value="<?php the_search_query(); ?>" placeholder="Search.."/>
<input class="btn btn-primary no-border" type="submit" class="search-submit" value="Search" />
</form>
</div>
<?php if(is_active_sidebar('main-sidebar')):?>
<?php dynamic_sidebar('main-sidebar');?>
<?php endif;?>
<?php get_header(); ?>
<!-- BLOG AREA -->
<section>
<hr class="no-margin" />
<?php if (have_posts()) : while(have_posts()) : the_post(); ?>
<div class="blog-container section-content">
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="box-layer custom-padding">
<section>
<h1><a href="<?php the_permalink(); ?>" class="gray"><?php the_title(); ?></a></h1>
By <a href="<?php the_author_posts() ?>"><?php the_author(); ?> </a> / On <?php echo get_the_date('F j, Y'); ?> / In <?php the_category(', '); ?>
<?php if (has_post_thumbnail()) : ?>
<figure> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('', array('class' => 'opacity-hover box-layer img-responsive')); ?></a>
</figure>
<?php the_content(); ?>
<?php endif; ?>
</section>
<?php endwhile; ?>
<?php endif; ?>
<section>
<div class="comment-section">
<?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || '0' != get_comments_number() ) : comments_template(); endif; ?>
</div>
</section>
</div>
<!-- RELATED ARTICLE AREA -->
<section>
<div class="box-layer related-articles custom-padding">
<h3 class="align-center">Related Articles</h3>
<?php $current_categories = get_the_category(); $first_category = $current_categories[0]->term_id;
$args = array(
'post_per_page' => 3,
'category__in' => array($first_category),
'post__not_in' => array($post->ID)
);
$related_articles = new WP_Query($args);
if ($related_articles->have_posts()) : ?>
<ul>
<?php while ($related_articles->have_posts()) : $related_articles->the_post(); ?>
<li class="col-md-4">
<?php if (has_post_thumbnail()) : ?>
<figure> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('', array('class' => 'opacity-hover box-layer img-responsive')); ?></a> </figure>
</figure>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php endif; ?>
</li>
<?php endwhile; ?>
<div class="clear"></div>
</ul>
<?php endif; ?>
<?php // Restore original Post Data wp_reset_postdata(); ?>
</div>
</section>
</div>
<!-- SIDEBAR AREA -->
<aside>
<div class="col-md-3 col-md-offset-1 margin-sidebar">
<?php get_sidebar(); ?>
</div>
</aside>
</section>
<?php get_footer(); ?>
<?php
/*
Theme Name:NeoBlog
Theme URI:http://www.wordpress.com
Author: Rishni Meemeduma
Description:This is a simple theme
Version:1.0;
*/
@import url("css/reset.css");
@import url("css/bootstrap.css");
@import url("css/style.css");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment