Archive for the ‘wordpress’ Category

Post orderby custom field

If you want to make posts orderby custom field … use below code .

proirity = Custom Field name

global $wp_query;

function priority_select($sql){

global $wpdb;

if (strpos($sql, ‘proirity’) !== false){

$sql = str_replace(”ORDER BY {$wpdb->postmeta}.meta_key”, “ORDER BY CAST({$wpdb->postmeta}.meta_key AS UNSIGNED)”, $sql);

}

return $sql;

}



add_filter(’query’, ‘priority_select’);

query_posts( array_merge(array(’meta_key’ => ‘proirity’, ‘orderby’=> ‘meta_value’, ‘order’ => ‘asc’), $wp_query->query));

// loop code

wp_reset_query();


Sorry, this file type is not permitted for security reasons

I can’t upload .3gp to wordpress.
Solution:
Edit wp-includes/functions.php,
search for:
1
‘mp4|m4v’ => ‘video/mp4′,
add a line after it:
1
‘3gp’ => ‘video/3gpp’,
Done!
You may want to add other filetypes you also enjoy here.

showing subcategories on WordPress category pages

show the subcategories for a given category on it’s category page .Basically you need to check whether there are any children, and if there are, list the categories with the current category as a parent or grandparent. The following code does just that:

if (is_category()) {
  $this_category = get_category($cat);
  if (get_category_children($this_category->cat_ID) != "") {
    echo "

Subcategories

"
; echo "
    "; wp_list_categories('orderby=id&show_count=0&title_li= &use_desc_for_title=1&child_of='.$this_category->cat_ID); echo "
"
; } }

Stop Junk Characters ‘â€TM’ from Appearing Instead of an Apostrophe

After my latest WordPress update (which as a manual one, with a whole lot of  mysql issues!) I finally got my blog up and running again, only to find all my apostrophes appearing as “â€TM” –stupid junk characters. After going into panic mode for about two minutes, I figured out the solution, at least in my case.

It was quite simple, jump in my wp-config, and comment out two lines.

# define(‘DB_CHARSET’, ‘utf8?);

# define(‘DB_COLLATE’, ”);

And just like that, all was normal again. Hope this helps someone.

After my latest WordPress update (which as a manual one, with a whole lot of  mysql issues!) I finally got my blog up and running again, only to find all my apostrophes appearing as “â€TM” –stupid junk characters. After going into panic mode for about two minutes, I figured out the solution, at least in my case.

It was quite simple, jump in my wp-config, and comment out two lines.

# define(‘DB_CHARSET’, ‘utf8?);

# define(‘DB_COLLATE’, ”);

And just like that, all was normal again. Hope this helps someone.

Display latest post title

just add this

it will add title with link inside

  • How to get thumb image from post

    Add this function to function.php file

    function getImage($num) {
    global $more;
    $more = 1;
    $link = get_permalink();
    $content = get_the_content();
    $count = substr_count($content, ‘
    $start = 0;
    for($i=1;$i<=$count;$i++) {
    $imgBeg = strpos($content, ”);
    $postOutput = substr($post, 0, $imgEnd+1);
    $postOutput = preg_replace(’/width=”([0-9]*)” height=”([0-9]*)”/’, ‘/width=”117″ height=”68″/’,$postOutput);
    $postOutput = preg_replace(’/alignright/’, ‘alignleft’,$postOutput);

    $image[$i] = $postOutput;
    $start=$imgEnd+1;
    }
    if(stristr($image[$num],’‘.$image[$num].”“; }
    $more = 0;
    }

    and call it as where you want to show image   .. inside loop.