Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
WordPress: Displaying Date (as an image) using PHP
Old 10-04-2011, 10:57 AM WordPress: Displaying Date (as an image) using PHP
Junior Talker

Posts: 3
Trades: 0
Hi, everyone. I am trying to put together a WordPress for a client and although I hate asking for help - I am at a total standstill! She wants date tabs on the left of each post (on the main homepage and then each post; NOT pages- obviously, since those aren't 'dated', per say...).

Here is the function.php code I am using:
Code:
// custom date tab - creates two divs
// first div pulls in a background png image named by date
// and adds year dynamically. Placed via css to left of post as
// a hanging tab.

remove_action('genesis_before_post_content', 'genesis_post_info');
add_action('genesis_before_post_content', 'family_tree_post_info');
function family_tree_post_info() {
    if(is_page()) return; // don't do post-info on pages
		echo '<div class="post-date-wrap">';
		echo '<div class="post-date post-date-background" style="background:url(';
		echo CHILD_URL;;
		echo '/images/date';
		echo the_time('F');
		echo '/';
		echo the_time('M');
		echo '.png) no-repeat 4px -3px">';
		echo the_time('Y');
		echo '</div>';
		echo '</div>';
		echo '<div class="post-info">';
        genesis_post_comments_link(__('Leave a Comment', 'child'), __('1 Comment', 'child'), __('% Comments', 'child'));
        edit_post_link(__('(Edit)', 'child'), '', ''); // if logged in
    	echo '</div>';
}
This shouldn't matter [much] - but here is the style.css for the post-dat:

Code:
.post-date-wrap {
	width: 65px;
	height: 73px;
	}

.content-sidebar .post-date-wrap {
	float: left;
	margin-top: -42px;
	margin-left: -107px;
	background: url(images/dates/bgd-left.png) no-repeat top left;
	}

.content-sidebar-sidebar .post-date-wrap {
	float: left;
	margin-top: -42px;
	margin-left: -84px;
	background: url(images/dates/bgd-left.png) no-repeat top left;
	}

.full-width-content .post-date-wrap {
	float: left;
	margin-top: -42px;
	margin-left: -89px;
	background: url(images/dates/bgd-left.png) no-repeat top left;
	}

.sidebar-content .post-date-wrap {
	width: 65px;
	height: 73px;
	float: right;
	margin-top: -42px;
	margin-right: -89px;
	background: url(images/dates/bgd-right.png) no-repeat top left;
	}

.sidebar-sidebar-content .post-date-wrap {
	width: 65px;
	height: 73px;
	float: right;
	margin-top: -42px;
	margin-right: -86px;
	background: url(images/dates/bgd-right.png) no-repeat top left;
	}

.sidebar-content-sidebar .post-date-wrap, .sidebar-content-sidebar .post-date {
	visibility: collapse;
	height: 0;
	width: 0;
	}

.post-date {
	width: 62px;
	height: 17px;
	display: inline;
	text-align: center;
	color: #4e260d;
	padding: 50px 0 0 5px;
	font-size: 9px;
	}

.content-sidebar .post-date, .content-sidebar-sidebar .post-date, .full-width-content .post-date {
	float: left;
	}

.sidebar-content .post-date, .sidebar-sidebar-content .post-date {
	float: right;
	}
Here are two pictures:
* I have one of these for every day; for each month - found in images/dates - thereafter organized by months (in written out for October, November; then 1.png; 2.png, etc. for each DAY of the month)



This is how it is coming up right now; only the year (that really small lettering that says 2011):

I need the images with the month & date to appear inside of that box/tab. I have been working on this for too long and cannot get it to go. My 'thing' is design, so I really hope you can all help me! I just can't get PHP down.. I am sure it is something so ridiculous that I cannot see.

Thanks for your help!!

- Nicole
weblogicgroup is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-04-2011, 11:16 AM Re: WordPress: Displaying Date (as an image) using PHP
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Based on this code:

PHP Code:
echo '/images/date';
echo 
the_time('F');
echo 
'/';
echo 
the_time('M');
echo 
'.png) no-repeat 4px -3px">';
echo 
the_time('Y'); 
if the post date was Jan 1st 2011 the output would be:

Code:
/images/dateJanuary/Jan.png) no-repeat 4px -3px">2011
I'm guessing the desired output would be:

Code:
/images/date/January/1.png) no-repeat 4px -3px">2011
Try this:
PHP Code:
<?php
remove_action
('genesis_before_post_content''genesis_post_info');
add_action('genesis_before_post_content''family_tree_post_info');
function 
family_tree_post_info() {
    if(
is_page()) return; // don't do post-info on pages
?>
    <div class="post-date-wrap">
        <div class="post-date post-date-background" style="background:url(<?php echo CHILD_URL?>/images/date/<?php echo the_time('F'); ?>/<?php echo the_time('j'); ?>.png) no-repeat 4px -3px">
        the_time('Y');
        </div>
    </div>
    <div class="post-info">
<?php
        genesis_post_comments_link
(__('Leave a Comment''child'), __('1 Comment''child'), __('% Comments''child'));
        
edit_post_link(__('(Edit)''child'), ''''); // if logged in
        
echo '</div>';
}
?>
If it doesn't work post the HTML output (specifically the style attribute).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-04-2011, 11:38 AM Re: WordPress: Displaying Date (as an image) using PHP
Junior Talker

Posts: 3
Trades: 0
Ahh! Awesome - thank YOU!

Now the image is showing up but the year is saying: the_time('Y'); -- in replace of "2011"
weblogicgroup is offline
Reply With Quote
View Public Profile
 
Old 10-04-2011, 11:43 AM Re: WordPress: Displaying Date (as an image) using PHP
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
My mistake. Change:
Code:
the_time('Y');
to:
PHP Code:
<?php echo the_time('Y'); ?>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-04-2011, 11:46 AM Re: WordPress: Displaying Date (as an image) using PHP
Junior Talker

Posts: 3
Trades: 0
Worked! Thanks SO much.. you really have no idea... I've been working on this for so long and can't go any further (well, I'm done really) until this. I have such problems with PHP. Been designing websites for about 16 years and just can't get PHP down.. seriously, thank you.. I can now sleep at night

- Nicole
weblogicgroup is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to WordPress: Displaying Date (as an image) using PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21377 seconds with 12 queries