search page different results

is_search() is going to return TRUE on every search you perform, so that won’t do what you need if I understand correctly. You’ll have to use a post_type conditional tag. But it shouldn’t be too difficult with something like if (is_search()) { if (get_post_type() == ‘type_1’) { //Do the right styling } else if (get_post_type() … Read more

Search page different title per results

For this to work, you will need to have your search results ordered by the post type. function order_by_pt($where,$qry) { if (is_main_query() && $qry->is_search()) { global $wpdb; $where = $wpdb->posts.’.post_type DESC’; } return $where; } add_action(‘posts_orderby’,’order_by_pt’,1,2); Then a Loop like this one will do what you want, if I understand you. $type_title=””; while (have_posts()) { … Read more

Get current post’s child page?

$ancestors = array(); $ancestors = get_ancestors($post->ID,’page’); $parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID; $parent should be the topmost page parent. However, if you are using a WordPress generated menu there is a pretty good chance that there is already a item identified by a CSS class as the parent. Take a good look at the … Read more

How get the 10 most viewed pages (not post)

If you want to query pages you have to choose post_type=page – of course. Another “problem” is that the commen count isn’t exactly representing post/page views. If you really want page views – not comment count – try something like the function below – I got that from here: http://wpsnipp.com/index.php/functions-php/track-post-views-without-a-plugin-using-post-meta/. function getPostViews($postID){ $count_key = ‘post_views_count’; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)