Set cookie for visitor

If you are looking for user only comments then you could try this one ( http://codex.wordpress.org/Function_Reference/wp_set_auth_cookie). This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead. Sets the authentication cookies based User ID. The $remember parameter increases the time that the cookie will be kept. … Read more

“if parent category is” conditional?

Your solution won’t work, because $ep_category->category_parent is ID (integer) and not slug (string). So this comparison doesn’t make any sense… 😉 One way to do this would be this function (from Codex): if ( ! function_exists( ‘post_is_in_descendant_category’ ) ) { function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) … Read more

How can I alter this code to accept a slug as well as an ID?

The Codex essentially explains how to do this: if ( $category_to_check = get_term_by( ‘name’, ‘fruit’, ‘category’ )) post_is_in_descendant_category($category_to_check->term_id); https://codex.wordpress.org/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category Putting it all together in your function you would have: if ( ! function_exists( ‘post_is_in_descendant_category’ ) ) { function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { if (!absint($cat)) … Read more

Echo array value

If you just need to have the print_array($var) provide an array of values, then you need to change the database function from $wpdb->get_results to $wpdb->get_var. You are retrieving just one value from the database, so get_var is the function which will return that specific value directly. Edit: You can create a comma separated list from … Read more

How to debug failed changes to posts?

I was finally able to get this to work by using php5-fpm instead of php5-cgi. First I removed the php5-cgi package via sudo apt-get autoremove –purge php5-cgi Then I installed php5-fpm via: sudo apt-get install php5-fpm After tweaking my server definition in Nginx a bit, the problem went away. Update I suspect this had more … Read more

Unexpected token ILLEGAL, even on clean install – jquery-issue?

It looks to me like you’re trying to utilize jQuery in custom code, but haven’t actually enqueue’d the jQuery script – This line gives it away (I think?): ReferenceError: jQuery is not defined if you are using wp_enqueue_script to bring in a custom .js file, make sure you set jquery as a dependancy wp_enqueue_script( ‘my-script’, … Read more

phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’

From what I can see, you are inserting data in table wp_commentmeta. However the column meta_id has a Primary Key restriction. You can see the table definition at http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta As meta_id has a Primary Key restriction, this column may only hold unique values. The insert statements you have posted show only unique values for meta_id, … Read more