andersonmultimedia
Forum Replies Created
-
Forum: Hacks
In reply to: Order search results by post typeI got it to work like this:
<?php add_filter('posts_orderby','my_sort_custom',10,2); function my_sort_custom( $orderby, $query ){ global $wpdb; if(!is_admin() && is_search()) $orderby = $wpdb->prefix."posts.post_type DESC, {$wpdb->prefix}posts.post_date DESC"; return $orderby; } ?>
Thanks.
Forum: Hacks
In reply to: Order search results by post typeDecided to dumb this down. Can anyone tell me how to modify this code so my post types display in DESC order alphabetically? All I need to do is make the program_listings display first in search results.
function filter_search($query) { if ($query->is_search) { $query->set('post_type', array('program_listings', 'post', 'knowledge_base', 'profile_cct', 'pages')); }; return $query; }; add_filter('pre_get_posts', 'filter_search');
Forum: Hacks
In reply to: Order search results by post typeI googled “arbitrary order sort algorithm” and found the following solution. But I don’t know how to incorporate it with my code from my original post above. Could you help me put this function code together?
public static function sortWords($inputArray){ $order=array("Banana","Orange", "Apple", "Kiwi"); $sorted_array = array_diff($inputArray,$order); sort($sorted_array); $rest_array = array_intersect($order,$inputArray); $result = array_merge($rest_array,$sorted_array); return $result; }
Forum: Hacks
In reply to: Order search results by post typeThanks for staying with me bcworkz. I could easily implement your last suggestion. And the logic behind it to use DESC is so simple. But I am afraid of the consequences of renaming post types this deep into a project we’ve been customizing for 5 months. I know there are lots of references in my style sheets, widgets, and child theme templates.
I had looked at usort() in the PHP manual, but didn’t understand exactly how to use it with my code.
This is the site I’m working on: https://avichai.pairsite.com/ (pw = letmesee)
Forum: Hacks
In reply to: Order search results by post typeYou could do multiple queries, one for each type in turn. Or sort each result into an array structure which is then used to drive the final output after all results are processed. Or use usort() on the results with a comparison function that uses your desired order.
Thanks bcworkz. I am not knowledgeable enough with php to implement any of these techniques. Which would you recommend? I need to make my search results post types appear in the order that they are listed in the array above.
Forum: Hacks
In reply to: Order search results by post typeThanks Tara. It does not. I need to manually make my ‘program_listings’ appear first, followed by ‘post’ , etc.
I got it. Just needed to target background with widget_yarpp_widget instead of yarpp_widget-2.suf-widget (I’m using Suffusion child theme). Thanks for steering me to the appropriate thread!
Thanks. That did get rid of the heading and the no posts message, but it leaves a little sliver of the background. This is what I grabbed from Firebug on it: `<aside id=”yarpp_widget-2″ class=”dbx-box suf-widget widget_yarpp_widget”>
<div class=”dbx-content”>
</aside>`Forum: Fixing WordPress
In reply to: How Can I make Current Tag stay highlighted?I just submitted to them – thanks. I assumed the theme author wasn’t going to offer support for another developer’s widget. BTW – the plugin I’m using is actually called xili-tidy-tags.
Forum: Fixing WordPress
In reply to: How Can I make Current Tag stay highlighted?Hi Tara. I am using a child theme of Suffusion.
Forum: Themes and Templates
In reply to: List other posts associated with current CPT taxonomy termavichai.pairsite.com/program-listings/neta-cet/
p/w = letmesee
Forum: Themes and Templates
In reply to: List other posts associated with current CPT taxonomy termIt doesn’t work right. Includes posts from parent terms, and I just want the last child terms related posts. Can anyone help?
Forum: Fixing WordPress
In reply to: Terms in Post Title BylineI resolved this by changing $taxonomy to ‘post_categories’ like:
<?php the_terms( $id, 'post_categories', $before, $sep, $after ); ?>
Forum: Fixing WordPress
In reply to: Terms in Post Title BylineForum: Fixing WordPress
In reply to: Nav menus current page link parent/ancestor highlightI have discovered that my technique of using #nav_menu-2 li.current_page_item in stylesheet is what’s keeping the subnav items (CPT taxonomy terms) highlighted when on the CPT archive pages. And the technique you’ve given me is keeping the main nav item highlighted when on the CPT archive pages and CPT single pages.
I just need to figure out how to also keep the subnav terms highlighted when on the single pages.