$querystr = ”
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = ‘message’
AND $wpdb->posts.post_status = ‘publish’
AND $wpdb->term_taxonomy.taxonomy = ‘taxonomy_name’
AND $wpdb->terms.slug = ‘term_name’
ORDER BY $wpdb->posts.post_date DESC
LIMIT 10
“;

$pageposts = $wpdb->get_results($querystr, OBJECT);

Advertisements

$creds = array();

$creds[‘user_login’] = $_POST[‘log’];
$creds[‘user_password’] = $_POST[‘pwd’];
$creds[‘remember’] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) )
if( $user->get_error_message() ){
$content .=’ERROR: Invalid username. Lost your password?‘;
}

Solution for another daemon running

Posted: September 29, 2011 in Linux Stuff

If you are encountered following error while starting your localhost. I came up with a soluton without any hassle

sandeep@rtcamp:~$ sudo /opt/lampp/lampp startStarting XAMPP for Linux 1.7.4…
XAMPP: Another web server daemon is already running.
XAMPP: Another MySQL daemon is already running.
XAMPP: Another FTP daemon is already running.
XAMPP for Linux started.

Solution: Stop your other services
TO DO SO
TO Stop another web server daemon
sudo /etc/init.d/apache2 stop

To Stop another MySQL daemon
sudo /etc/init.d/mysql stop

To Stop another FTP daemon
sudo /etc/init.d/ftp stop

Restart your localhost
sudo /etc/opt/lampp/lampp restart


Translates dates from mysql format to any format acceptable by the php date() function
Syntax

mysql2date($dateformatstring, $mysqlstring, $translate = true)

To get post title

Posted: June 29, 2011 in WordPress

<?php

global $post;
$this_post_id = $post->ID;

$post_id = get_post($this_post_id, ARRAY_A);

echo $title = $post_id->post_title;
?> 


get_col($wpdb->prepare(”
SELECT ID
FROM $wpdb->posts
WHERE SUBSTR($wpdb->posts.post_title,1,1) = %s
ORDER BY $wpdb->posts.post_title”,$first_char));

if ($postids) {
$args=array(
‘post__in’ => $postids,
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => -1,
‘caller_get_posts’=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo ‘List of Posts Titles beginning with the letter ‘. $first_char;
while ($my_query->have_posts()) : $my_query->the_post(); ?>

<a href="” rel=”bookmark” title=”Permanent Link to “>


Note. rsync doesn’t (by default) actually copy whole files between machines. Rather, it uses the rsync algorithm to find the differences between the two files and only sends sufficient information that is needed to make the destination file be identical with the source file. This is much more complicated than just copying the file, but has the potential for drastically minimizing the amount of data that has to be copied.

1. Check whether SVN installed or not by using “svn”

2. if not install sudo apt-get install svn

3. Import Base theme( fresh ) on server using
sudo svn import /home/test/Desktop/your-projecthttp://svn.domain-.com/wordpress/themes/your-project-name/trunk -m “Importing your-Theme Theme”

4. Checkout all the files on workspace ( remote copy of files on local IDE ) using
Server Path to Local path ( IDE location)
sudo svn co http://svn.domain-.com/wordpress/themes/your-project-name/trunk//home/test/server/wp-content/themes/Your-Theme

5. Permit those remote files as Readable Writable & Executable ( 4 + 2 + 1 ) using

sudo chmod a+rw /home/test/server/wp-content/themes/Your-Theme -R

OR

sudo chmod -R 7( user )7 ( group ) 7( world ) /home/test/server/wp-content/themes/Your-Theme

6. To commit local copy in local repository

sudo svn commit /home/test/server/wp-content/themes/Your-Theme

7. In order to make live site export fresh backup from repository

sudo svn export http://svn.domain-.com/wordpress/themes/your-project-name/trunk//home/test/Desktop/location

8. Import exported copy to live environment using rsync or FTP whichever convenient