How to filter my search in post if contains a word in title, content or excerpt?

Well, for whoever went under the same question, I found the solution: I’ve changed the filter and looks like this now: add_filter( ‘posts_where’, ‘general_filter’, 10, 2 ); $posts = new WP_Query($args); remove_filter( ‘posts_where’, ‘general_filter’, 10, 2 ); and the function… function general_filter( $where, &$wp_query ) { global $wpdb; if ( $search_term = $wp_query->get( ‘search_prod_title’ ) … Read more

How can I check if a var is equal a translated label?

You need to pass the text domain too. Assuming that you have the proper .mo and .po file, and loaded the text domain successfully: if( $_POST[“save”] === __( ‘Publish’, ‘text-domain’ ) ){ //do something } But this is not generally a good idea. You should do your checks based on something more certain, not a … Read more

wp-cli post create & media import issues

So I just ended up doing a query on the database for the link of the image: wp db query “SELECT guid FROM wp_posts WHERE ID=’ID_FROM_MEDIA_IMPORT’” –silent –skip-column-names I wrote this bash script for the whole process: post-create.sh PATH_TO_IMAGE.FILETYPE “TITLE” imageID=$(wp media import $1 –porcelain) imageLINK=$(wp db query “SELECT guid FROM wp_posts WHERE ID=’$imageID'” –silent … Read more

Excerpts on category page

Try this and place in your functions.php file: function custom_excerpt_length( $length ) { return 35; } add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 ); function excerpt_more( $more ) { return sprintf( ‘%2$s’, get_permalink( get_the_ID() ), __( ‘Read More’, ‘textdomain’ ) ); } add_filter( ‘excerpt_more’, ‘excerpt_more’ );