Adding Multiple “Parents” in get_categories

You cannot get it in one call. Instead, make multiple calls, then sort the data each call gave you into a single array, and take the top 5 in the new list. e.g. $args=array( ‘orderby’ => ‘count’, ‘order’ => ‘DESC’, ‘parent’ => ‘599’, ‘number’ => ‘5’ ); $categories=get_categories($args); $args2=array( ‘orderby’ => ‘count’, ‘order’ => ‘DESC’, … Read more

Using static pages on WordPress site

I would suggest making your own page template. Start by moving the files into your WordPress theme folder, and giving them a name. Like page-foo.php, page-bar.php, so on. Then on the top of these new files add PHP like the below, changing the Template Name to something that makes sense to you. <?php /* Template … Read more

How to Add Additional Search Button?

You might have to check which button was clicked by user, weather it is search all post or search my post, based on that you can apply filter. Try this.. function search_author($query) { if($query->is_search) { if($query->query_vars[‘author’]==’Search My Posts’) { $query->set(‘author’, get_current_user_id()); } } return $query; } add_filter(‘pre_get_posts’,’search_author’);

Custom Form not generating URL

The problem is problably here: <form id=”oselector” method=”GET” action=”<?php the_permalink(); ?>”> Your code is not in the WordPress Loop. According to the Function Reference (emphasis added): the_permalink() – Displays the URL for the permalink to the post currently being processed in The Loop. This tag must be within The Loop, and is generally used to … Read more

How to Render Post Types in RSS Feed?

Write a small custom plugin wich a function, that enhance the default query for feeds. The example below add all custom post types via get_post_types()to the default feed. // add custom post type to wp post-feed add_action( ‘request’, ‘fb_add_to_feed’ ); // add to post-feed function fb_add_to_feed ( $request ) { if ( isset( $request[‘feed’] ) … Read more

custom user meta query

Actually i figured it out now using join SELECT a.ID FROM wp_users a INNER JOIN wp_usermeta b ON b.user_id = a.ID AND ( ( b.meta_key = ‘firstname-groom’ AND b.meta_value LIKE ‘Darren’ ) OR ( b.meta_key = ‘firstname-bride’ AND b.meta_value LIKE ‘Someone’ ) OR ( b.meta_key = ‘lastname-bride’ AND b.meta_value LIKE ‘Cool’ ) ) INNER JOIN … Read more