Posts filed under ‘Wordpress’

Building Custom WordPress Theme

<![CDATA[You want to build your own WordPress theme but in a very simple way, then you dont need to edit the default wordpress theme, just create a new one with just 5 files. That is why I will share a simple version of the theme I used on

index.php(main stuff)

<!DOCTYPE html>
<html lang="en"><head>
    <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta name="google-site-verification" content="T8yRQAwK80tGKOWA-nTlOAjNo37ye8C8UIvgM-6zW0I" />
    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/html5.js"></script>
	<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/custom.js"></script>
    <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/reset.css" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/960.css" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/custom.css" />
    <link rel="icon" href="/favicon.ico?1" type="image/x-icon" />
    <link rel="shortcut icon" href="/favicon.ico?1" type="image/x-icon" />
    <?php if(!is_single()){?><link rel="image_src" href="<?php bloginfo('stylesheet_directory'); ?>/images/share.gif?1" /><? }?>
    <?php wp_head();?>
    <script type="text/javascript">

		var _gaq = _gaq || [];
		_gaq.push(['_setAccount', 'UA-3174937-16']);

		(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


<body onLoad="ready()">
	<div class="blog container_16">
    	<header class="grid_16">
        	<h1 class="grid_12 alpha"><a href="<?php bloginfo('url');?>" class="logo ti">Sofie Kalenius</a></h1>
        	<aside class="grid_4 omega">
                <form id="searchForm" method="get" action="<?php bloginfo('url');?>"><input type="text" name="s" value="Search..." /><input type="submit" value=""/></form>
                <div class="networks"><a href="" class="nw1 ti">linkedin</a><a href="" class="nw2 ti">twitter</a><a href="" class="nw3 ti">facebook</a><a href="/feed/" class="nw4 ti">rss</a><a href="" class="nw5 ti">flickr</a></div>
				<?php if(is_category()){$cat = get_query_var('cat');$currentCat = get_category($cat);}
				$categories=get_categories();foreach($categories as $cat){?><li><a href="<?=get_category_link($cat->term_id);?>" <? if($currentCat->slug == $cat->category_nicename){?>class="on"<? }?>><?=$cat->cat_name;?> (<?=$cat->category_count;?>)</a></li><? }?>
				<?php $pages=get_pages();foreach($pages as $pagg){?><li><a href="<?=get_page_link($pagg->ID);?>"><?=$pagg->post_title;?></a></li><? }?>
    	<div class="main grid_16">
        	<section class="posts grid_13 alpha">

				<?php if (have_posts()) : ?>
					<?php while (have_posts()) : the_post();?>
                        <div class="post">
                            <div class="date grid_2 alpha"><section><p class="top"><?php the_time('d') ?></p><p class="bottom"><?php the_time('M') ?> <?php the_time('y') ?></p></section></div>
                            <div class="content grid_11 omega spacing80">
                                <a href="<? the_permalink() ?>#comments" class="comment_no"><?php comments_number('0','1','%'); ?></a>
                                <h2><a href="<? the_permalink() ?>" rel="bookmark" class="title"><? the_title();?></a></h2>
                                <? if(has_tag()){?><div class="tags"><?php the_tags('Tags: ', ', '); ?></div><? }?>
                                <article><?php the_content('Read the rest of this entry &raquo;'); ?></article>

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

                <nav class="grid_11 prefix_2 alpha omega"><section><?php next_posts_link('&laquo; Older Posts') ?>&nbsp;</section><section>&nbsp;<?php previous_posts_link('Newer Posts &raquo;') ?></section></nav>
        	<aside class="sidebar grid_3 omega">

                        if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
                    <?php endif; ?>

    <footer class="footer">
    	<div class="container_16">
			<? $categories=get_categories();foreach($categories as $cat){ if($first) echo " | ";$first=1;?><a href="<?=get_category_link($cat->term_id);?>"><?=$cat->cat_name;?></a><? }
            $pages=get_pages();foreach($pages as $pagg){?> | <a href="<?=get_page_link($pagg->ID);?>"><?=$pagg->post_title;?></a><? }?><br />
            <p class="copyright">Copyright Sofie Kalenius 2010. All Rights Reserved. Designed by <a href="/contact">Sofie Kalenius</a> | Developed by <a href="">geryit</a></p>

        <?php wp_footer(); ?>


body{font-family:Arial, Helvetica, sans-serif;background:#f6f5f5 url(images/body_bg.png) repeat-x center top;font-size:12px;}
input,select,textarea{font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#8f8e90;}
input[type=submit]{background:#1e7972;color:#fff;border:none;width:auto;padding:5px 40px;}

.blog>header>aside{height:94px;background:url(images/search_and_networks_bg.png) right top;}
.blog>header>aside>form>input[type=text]{width:162px;height:19px;border:2px solid #e3e2e2;background:#e9e9e9;padding:5px;padding-right:45px;}
.blog>header>aside>div>a.nw1{background-position:0px top;}
.blog>header>aside>div>a.nw1:hover{background-position:0px bottom;}
.blog>header>aside>div>a.nw2{background-position:-47px top;}
.blog>header>aside>div>a.nw2:hover{background-position:-47px bottom;}
.blog>header>aside>div>a.nw3{background-position:-93px top;}
.blog>header>aside>div>a.nw3:hover{background-position:-93px bottom;}
.blog>header>aside>div>a.nw4{background-position:-138px top;}
.blog>header>aside>div>a.nw4:hover{background-position:-138px bottom;}
.blog>header>aside>div>a.nw5{background-position:-182px top;}
.blog>header>aside>div>a.nw5:hover{background-position:-182px bottom;}
.blog>header>ul{width:100%;margin-top:50px;padding:10px 0;border-top:1px solid #e9e8e8;border-bottom:1px solid #e9e8e8;}
.blog>header>ul>li>a{height:25px;line-height:25px;font-size:15px;color:#424242;padding:0 10px;}
.blog>.main>.posts>.post a{display:inline;float:none;}
.blog>.main>.posts>.post img{display:inline;}
.blog>.main>.posts>.post .wp-smiley{border:0!important;margin:0!important;}
.blog>.main>.posts>.post>.content{background:#eaebeb url(images/bgitem2.png) no-repeat right top;padding:20px 40px 40px;}
.blog>.main>.posts>.post>.content>a.comment_no{width:40px;height:70px;float:right;margin:-18px -38px 0 0;font-size:15px;color:#f6f5f5;text-align:center;line-height:55px;padding-left:25px;}
.blog>.main>.posts>.post>.content>article>p img{border:5px solid #999;margin:0 15px 10px 0;padding:0;}
.blog>.main>.sidebar>ul>li>h3{font-size:20px;color:#424242;background:url(images/bar1.png) repeat-x bottom;padding-bottom:5px;margin-bottom:5px;}
.blog>.main>.sidebar>ul>li>ul>li{width:100%;padding:5px 0;}
.blog>.main>.sidebar>ul>li>ul>li>a{font-size:11px;color:#424242;background:url(images/bull1.png) no-repeat left center;text-indent:7px;}
.blog>.main>.sidebar>ul>.featured>ul>li{width:100%;border-bottom:1px solid #eee;padding:10px 0;}
.blog>.main>.sidebar img{padding:2px;}

.blog>.main>.posts>.post>.comments{margin-top:30px;background:#eaebeb;padding:20px 40px 40px;}
.blog>.main>.posts>.post>.comments>ul>li a{float:none;display:inline;clear:none;}
.blog>.main>.posts>.post>.comments>ul>li>div>img{padding:0 5px 5px 0;}
.blog>.main>.posts>.post>.comments>#respond #commentform p{margin-top:10px;}
.blog>.main>.posts>.post>.comments>#respond #commentform label{margin:10px 0 0 10px;}
.footer{width:100%;height:100px;background:#1e7972 url(images/footer_bg.png) repeat-x;}
.footer>div>.copyright a{float:none;display:inline;color:#CFCFCF;}
.footer>div>.copyright a:hover{color:#333;}

p img {padding: 0;max-width: 100%;float:none;}
img.centered {display: block;margin-left: auto;margin-right: auto;}
img.alignright {padding: 4px;margin: 0 0 2px 7px;display: inline;}
img.alignleft {padding: 4px;margin: 0 7px 2px 0;display: inline;}
.alignright {float: right;}
.alignleft {float: left;}
.wpcf7 p{padding-top:10px!important;}

comments.php(customize comment form)


// Do not delete these lines
	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('Please do not load this page directly. Thanks!');

	if ( post_password_required() ) { ?>
		<p class="nocomments">This post is password protected. Enter the password to view comments.</p>

<div class="comments push_2 grid_11 alpha spacing80">
<!-- You can start editing here. -->

<?php if ( have_comments()) : ?>
	<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>

	<div class="navigation">
		<div class="alignleft"><?php previous_comments_link() ?></div>
		<div class="alignright"><?php next_comments_link() ?></div>

		<?php wp_list_comments('callback=custom_comment_template'); ?>

 <?php else : // this is displayed if there are no comments so far ?>

	<?php if ( comments_open() ) : ?>
		<!-- If comments are open, but there are no comments. -->

	 <?php else : // comments are closed ?>
		<!-- If comments are closed. -->
		<p class="nocomments">Comments are closed.</p>

	<?php endif; ?>
<?php endif; ?>

<?php if ( comments_open() ) : ?>

<div id="respond">

<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>

<div class="cancel-comment-reply">
	<small><?php cancel_comment_reply_link(); ?></small>

<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
<p>You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in</a> to post a comment.</p>
<?php else : ?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

<?php if ( is_user_logged_in() ) : ?>

<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p>

<?php else : ?>

<p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>

<p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>

<p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>

<?php endif; ?>

<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->

<p><textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea></p>

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>


<?php endif; // If registration required and not logged in ?>
<?php endif; // if you delete this the sky will fall on your head ?>

functions.php(customize comments view)

'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
'after_title' => '</h3>',

function custom_comment_template($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment; ?>
	<li id="comment-<?php comment_ID(); ?>">
        <div><?php echo get_avatar($comment,$size='48'); ?><?php printf(__('<cite>%s</cite> <span>says:</span>'), get_comment_author_link()) ?><br /><span class="date"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></span><br /><span class="comment_text"><?=get_comment_text();?></span></div>

require_once (TEMPLATEPATH . '/widgets.php');

Click here for the entire theme files


15,08,2010 at 10:52 Yorum bırakın

Need a Simple Plugin To Share Your WordPress Blog Posts On Facebook?


I was looking for a plugin that will let me add the current post or page to my Facebook Mini-Feed but could not find a good one. Here is the solution to share your posts with others on facebook. Download this simple plugin, extract it to plugins folder of your blog, activate and add a new post. You will see a popup screen which connects you to facebook (Disable your popup blocker if you dont see the window ).]]>

12,04,2010 at 4:45 4 yorum

WordPress 3.0 Beta is out

<![CDATA[Remember when I posted earlier about the Twitter account, and I said that hopefully you’d find out later today what has been keeping us all so busy? Beta testers, this is your moment: the WordPress 3.0 Beta 1 has arrived!

This is an early beta. This means there are a few things we’re still finishing. We wanted to get people testing it this weekend, so we’re releasing it now rather than waiting another week until everything is finalized and polished. There’s a ton of stuff going on in 3.0, so this time we’re giving you a list of things to check out, so that we can make sure people are testing all the things that need it.

You Should Know:

The custom menus system (Appearance > Menus) is not quite finished. In Beta 2, the layout will be different and a bunch of the functionality will be improved, but we didn’t want to hold things up for this one screen. You can play with making custom menus, and report bugs if you find them, but this is not how the final screen will look/work, so don’t get attached to it.
The merge! Yes, WordPress and WordPress MU have merged. This does not mean that you can suddenly start adding a bunch of new blogs from within your regular WordPress Dashboard. If you’re interested in testing the Super Admin stuff associated with multiple sites, you’ll need some simple directions to get started.
We’re still fiddling with a few small things in the UI, as we were focused on getting the more function-oriented code finished first. For example, we’re getting a new icon for the Super Admin section.
Things to test:

Play with the new default theme, Twenty Ten, including the custom background and header options.
Custom Post Type functionality has been beefed up. It’s really easy to add new types, so do that and see how it looks!
WordPress MU users should test the multiple sites functionality to make sure nothing broke during the merge.
Already have a test install that you want to switch over to the beta? Try the beta tester plugin.

Testers, don’t forget to use the wp-testers mailing list to discuss bugs you encounter.

We hope you like it! And if you don’t, well, check back when beta 2 is ready.

Download the WordPress 3.0 Beta 1 now!

Post from WordPress Blog]]>

05,04,2010 at 0:03 Yorum bırakın

My First WordPress CMS Plugin

<![CDATA[Rafineri was founded in 2001 and became one of Turkey’s fastest growing acencies.
You can see the screen shots of plugin here.]]>

21,03,2010 at 22:13 Yorum bırakın

Any problems with front-end or back-end?

<![CDATA[Stack Overflow is a programming Q & A site that’s free. Free to ask questions, free to answer questions, free to read, free to index, built with plain old HTML, no fake rot13 text on the home page, no scammy google-cloaking tactics, no salespeople, no JavaScript windows dropping down in front of the answer asking for $12.95 to go away. You can register if you want to collect karma and win valuable flair that will appear next to your name, but otherwise, it’s just free. And fast. Very, very fast.

We don’t run Stack Overflow. You do. Stack Overflow is collaboratively built and maintained by your fellow programmers. Once the system learns to trust you, you’ll be able to edit anything, much like Wikipedia. With your help, we can build good answers to every imaginable programming question together. No matter what programming language you use, or what operating system you call home — better programming is our goal.

Stack Overflow is as frictionless and painless to use as we could make it. We believe finding the right answer to your programming questions should be as easy as falling into the pit of success. And maybe even a little fun along the way.

So What? Who cares? Isn’t this just like a dozen other websites?

What’s so special about this? Well, nothing, really. It’s a programming Q&A website. The only unusual thing we do is synthesize aspects of Wikis, Blogs, Forums, and Digg/Reddit in a way that is somewhat original. Or at least we think so.

Visit the website]]>

19,03,2010 at 21:12 Yorum bırakın Downtime Summary

<![CDATA[Today was down for approximately 110 minutes, our worst downtime in four years. The outage affected 10.2 million blogs, including our VIPs, and appears to have deprived those blogs of about 5.5 million pageviews.

What Happened: We are still gathering details, but it appears an unscheduled change to a core router by one of our datacenter providers messed up our network in a way we haven’t experienced before, and broke the site. It also broke all the mechanisms for failover between our locations in San Antonio and Chicago. All of your data was safe and secure, we just couldn’t serve it.

What we’re doing: We need to dig deeper and find out exactly what happened, why, and how to recover more gracefully next time and isolate problems like this so they don’t affect our other locations.

I will update this post as we find out more, and have a more concrete plan for the future.

I know this sucked for you guys as much as it did for us — the entire team was on pins and needles trying to get your blogs back as soon as possible. I hope it will be much longer than four years before we face a problem like this again.

Update 1: We’ve gathered more details about what happened. There was a latent misconfiguration, specifically a cable plugged someplace it shouldn’t have been, from a few months ago. Something called the spanning tree protocol kicked in and started trying to route all of our private network traffic to a public network over a link that was much too small and slow to handle even 10% of our traffic which caused high packet loss. This “sort of working” state was much worse than if it had just gone down and confused our systems team and our failsafe systems. It is not clear yet why the misconfiguration bit us yesterday and not earlier. Even though the network issue was unfortunate, we responded too slowly in pinpointing the issue and taking steps to resolve it using alternate routes, extending the downtime 3-4x longer than it should have been.

Source : WordPress Weblog]]>

24,02,2010 at 14:42 Yorum bırakın

To Get First Image From Post (WP)

<![CDATA[I want to share the code I used for my blog. I needed to get the first attachment from each post and show at frontpage, so the solution is below. You have to put this in the loop.

$content = get_the_content();
preg_match_all('/<img[^>]+>/i',$content, $result);
$thumb = $result[0][0];


19,02,2010 at 23:57 Yorum bırakın


Haziran 2017
« Ara    

Posts by Month

Posts by Category