How can i make a search box to search by custom field

The generated SQL for that query is going to look something like: SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) WHERE 1=1 AND wp_posts.post_type=”post” AND (wp_posts.post_status=”publish”) AND ((wp_postmeta.meta_key = ‘culoare’ AND CAST(wp_postmeta.meta_value AS … Read more

Ajaxurl suddenly not defined

take a look here: http://codex.wordpress.org/Function_Reference/wp_localize_script First add Data in your php file // Register the script first. wp_register_script( ‘some_handle’, ‘path/to/myscript.js’ ); // Now we can localize the script with our data. $translation_array = array( ‘some_string’ => __( ‘Some string to translate’ ), ‘a_value’ => ’10’ ); wp_localize_script( ‘some_handle’, ‘object_name’, $translation_array ); // The script can … Read more

memcache vs memcached?

The short answer: Either one is what you are looking for, but my first choice would be memcache (the first one you listed), purely based on its correct use of nomenclature. Now here’s how I came to that conclusion: Here is a quick backgrounder in naming conventions (for those unfamiliar), which explains the frustration by … Read more

Let users upload image(s) to the post from front end

wp_insert_attachment returns the resulting post_ID of attachment record created in posts table, so you will need to add these IDs (multiple) in the post meta table using update_post_meta as suggested in code below: $attchmentIds = array(); if ($_FILES) { foreach ($_FILES as $file => $array) { $newupload = insert_attachment($file,$pid); $attchmentIds[] = $newupload; } }; /*The … Read more

how to add a div inside wp_page_menu

The question is light on detail but I’d lean toward a custom Walker: class My_Page_Walker extends Walker_Page { function end_el( &$output, $page, $depth = 0, $args = array() ) { $output .= ‘<span>After the Anchor</span></li>’; } } $args = array( ‘walker’ => new My_Page_Walker ); wp_list_pages( $args ); That should insert content just before the … Read more

Deactivate a plugin on wp version

The problem is not version_compare, the problem is that register_activation_hook is just a shortcut for add_action( ‘activate_’ . $file, $function ); where $file is plugin_basename( __FILE__ ); and __FILE__ is your main plugin file absolute path. So, what your code does is to call dw_deactivate_theme_options() when the action ‘activate_’ . $plugin is fired. But this … Read more

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