Getting post thumbnail from post id
To get the thumbnail image with post id $post_id: <?php echo get_the_post_thumbnail( $post_id, ‘thumbnail’) ?>
Calling remote url in php
File get contents: To display a contents in a remote url : echo $file = file_get_contents(‘http://www.example.com/’); Php curl <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, “http://www.example.com/”); curl_exec($ch); curl_close($ch); ?>
To write contents into a file using php:
Print array to file php: Here array : $woocommerce File name : filename-sample.txt file_put_contents(‘filename-sample.txt’, print_r($woocommerce, true));
Displaying php errors
Enable error displaying in php, add any of the following code in your config file: ini_set(‘display_errors’, 1); ini_set(‘display_startup_errors’, 1); error_reporting(E_ALL); display_errors = on; <?php // Turn off all error reporting error_reporting(0); // Report simple running errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Reporting E_NOTICE can be good too (to report uninitialized // variables or catch variable name misspellings …) error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // Report all errors except E_NOTICE error_reporting(E_ALL & ~E_NOTICE); // Report all PHP errors (see changelog) error_reporting(E_ALL); // Report all PHP errors error_reporting(-1); // Same as error_reporting(E_ALL); ini_set(‘error_reporting’, E_ALL); ?> Refe: http://php.net/manual/en/function.error-reporting.php
Including taxonomies and tags in wordpress search
To include search in wordpress, add code from below link in functions.php // search all taxonomies, based on: http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23 function atom_search_where($where){ global $wpdb; if (is_search()) $where .= “OR (t.name LIKE ‘%”.get_search_query().”%’ AND {$wpdb->posts}.post_status = ‘publish’)”; return $where; } function atom_search_join($join){ global $wpdb; if (is_search()) $join .= “LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER…