Post your trick

handling custom form in wordpress

I had a custom login form in WP(3.1.2) and the problem i was facing is whenever the form was submitted i used to get empty $_POST array.This was my code

<form method=”post” action=”<?php echo bloginfo(’url’).’/?page_id=221′; ?>”>

After some google search I found the solution which was :

<form method=”post” action=”<?php echo $_SERVER['PHP_SELF'].’/?page_id=221′; ?>”>

which means if you are submitting the form on the same page use $_SERVER else you wont get the data in post


Wordpress – different single.php for different categories

if you have a category called photos and another category called videos , you need to format the single.php differently for each category . this is easy and you can just write the following code in single.php :

if ( in_category(’2′) ) {
include(TEMPLATEPATH . ‘/single-kodetricks.php’);
}
else
include(TEMPLATEPATH . ‘/single-blog.php’);


Post A Trick !

How does "Kodetricks" work?

We at kodeplay like to share knowledge. With Kodetricks, even you can join us. All you need to do is post a programming related trick if you have one or rate a trick if you like someone else's.



Technology

Contact Us