Jesse
  • Member for 10 years, 3 months
  • Last seen more than 4 years ago
Hook when category is added to post
Accepted answer
10 votes

You may want to try: do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); You can find it under this Docs and the action is located at wp-includes/taxonomy....

View answer
Getting the Current User
Accepted answer
8 votes

Call the function get_currentuserinfo() on the next line after declaring the global variable $current_user What is the difference between wp_get_current_user() and get_currentuserinfo()? Below is a ...

View answer
How to set and use global variables? Or why not to use them at all
8 votes

Your question is involved with how php works. Take $wpdb as example $wpdb is a well-known global variable. Do you know when it'll be declared and assigned with values ? Every page loaded, yep, ...

View answer
Run a function when a new site is created in Wordpress Multisite
5 votes

I guess you are looking for an action/filter. wpmu_new_blog this action is fired in wpmu_create_blog function (wp-includes/ms-functions.php) do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, ...

View answer
Reverse chronology of post listing
5 votes

You can add code below to the beginning of loop.php add_action('pre_get_posts', 'wpse_change_post_order'); function wpse_change_post_order($query){ $query->set('order','ASC'); $query->...

View answer
Is it safe to assume that a nonce may be validated more than once?
Accepted answer
5 votes

1, the nonce lifetime is about 24 hours by default actually. take a look at wp_verify_nonce function. To be more accurate, the lifetime is controlled by filter apply_filters( 'nonce_life', ...

View answer
Use 'medium' size with catch_that_image() function
Accepted answer
4 votes

When the first image is a Wordpress image attachment. in 3.6, there is an easier way. function get_first_image_medium_size_url($post_id) { if(!$images = get_attached_images($post_id)) return ...

View answer
Better wordpress attachment query than this
Accepted answer
4 votes

I don't have the data to test so the code below may be wrong. add_filter('posts_search', 'set_is_tax_to_true' ,10,2); function set_is_tax_to_true($search,$query){ $query->is_tax = true; } $...

View answer
How to get the post count for the last x days filtering by categories
2 votes

function get_days_ago_post_count_by_categories($ids){ $date_query = array( array( 'after'=>'4 days ago', '...

View answer
How can I get a list of comments by target
Accepted answer
2 votes

When it comes to retrieve posts, it's supposed to call WP_Query. WP_Query has an argument called meta_query but it doesn't have comment_query. So it might need a trick to achieve what you want, $...

View answer
Cannot install plugins even though www-data has write permissions
2 votes

I think, I've answered a similar question here before. OP claims all file permission are set correctly but still ask for ftp credentials. Well, this is very weird. But I think, it is still about ...

View answer
Search Post Title Only
Accepted answer
2 votes

I didn't test the code below, but I guess it works. /** * Search SQL filter for matching against post title only. */ function __search_by_title_only( $search, &$wp_query ) { /*my solution *...

View answer
Inserting large amounts of data into a custom table during plugin install
Accepted answer
2 votes

I have some suggestions for you: 1, create MySQL insert queries on your own. 2, combine multiple insert values queries into one like values(1,2,3),(4,5,6) 3, use $wpdb->query then you need to ...

View answer
Randomly select one of last 3 posts
1 votes

$args=array( 'orderby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 3, 'offset' => $offset, ); $q = new WP_Query($args); if($q-&...

View answer
Run function on settings save
Accepted answer
1 votes

I'm not familiar with wordpress settings api but I know those options generated by settings api are handled/saved in wp-admin/options.php Unfortunately, if ( isset( $_POST[ $option ] ) ) { ...

View answer
How to create an overview of posts with the same tag?
Accepted answer
1 votes

foreach( $posts_array as $post ) { echo the_title(); } I think the problem is you call the_title() without setup_postdata first If I were you, I'll simply use $post->post_title. foreach( $...

View answer
Sidebars are no longer working
Accepted answer
1 votes

uploading a fresh version of widgets.php which widgets.php? I guess you updated wp-admin/includes/widgets.php? you actually need to update wp-includes/widgets.php where dynamic_sidebar function ...

View answer
How do I add a listbox to the TinyMCE editor?
1 votes

I think there is one short solution for this: var mlb = cm.createListBox('columns', { title : 'Add a Column', onselect : function(v) { /* ...

View answer
Get category id when SEO URL is turned on
0 votes

function myFilter2($query) { if ($query->is_category()) { $currently_listing_categories = $query->get('cat'); print_r($...

View answer
Can't Auto-Update, but permissions are good?
Accepted answer
0 votes

If you're pretty sure about that the file owner of wordpress folder is as same as that one who runs apache. (use ps aux|grep 'httpd' or ps aux|grep 'apache') Here is a lousy solution for you: ...

View answer
Plugin update, is a deactivation and activation done?
Accepted answer
0 votes

According to the source code of wp-admin/includes/class-wp-upgrader.php Single plugin update: add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2); ...

View answer
reorder a WP_Query, using a dropdown
Accepted answer
0 votes

I guess the problem is $qry = new WP_Query(array('category_name'=>$GLOBALS['city'],'order'=>$orderby)); Let's just say $orderby is orderby=title&order=ASC Then the order argument of ...

View answer
URL rewrite breaking pagination
0 votes

This works: mysite.com/sermon/term/childterm/page2/ This does not: mysite.com/sermon/term/childterm/page2/ according to your rewrite rule, I guess what you mean is This works: mysite.com/...

View answer
Why this filter hook is not working when passing parameters?
Accepted answer
0 votes

try this $users = apply_filters('my_get_users',$group);

View answer
Get the current page URL (including pagination)
-1 votes

wp_guess_url is what you are looking for. Guess the URL for the site. Will remove wp-admin links to retrieve only return URLs not in the wp-admin directory.

View answer