How to make search include data from wp_postmeta?
If your up for using a plugin, Relevanssi – A Better Search might be worth trying out. The standard (free) version supports searching post meta.
If your up for using a plugin, Relevanssi – A Better Search might be worth trying out. The standard (free) version supports searching post meta.
Regex expression for redirecting image URLs to another folder
Displaying Post with Custom URL with RewriteRule or add_rewrite_rule
There’s author_can() for that: add_action( ‘loop_start’, ‘wpse105294_nofollow_author’ ); function wpse105294_nofollow_author() { ! author_can( $GLOBALS[‘post’]->ID, ‘edit_others_posts’ ) AND add_filter( ‘the_content’, ‘cn_nf_url_parse’); } So you only add that filter callback for authors and other roles that don’t have the possibility to edit_others_posts. By default this is Subscriber and Author. For more info, take a look at the … Read more
Instead of index.php/reco/?b=$1, try this: “$wp_rewrite->index?pagename=reco&b=” . $wp_rewrite->preg_index( 1 ) You should also append a $ to your reco/([^/]*)/? regex to ensure the rule only matches the entire path, and not just the beginning. Then flush your rules afterwards (just re-save your permalink settings in admin). Update: Try using the page_rewrite_rules filter instead, and use … Read more
Let’s give it a try: $str=”<img src=”http://myserver.mydomain/picture.png” />”; $pattern =’#<img src=”http://.*/(.*)” />#’; $replace=”<img src=”http://http://i0.wp.com/$1?quality=70&strip=all />””; $result = preg_replace($pattern, $replace, $str); The $pattern is quite simple and very specific. You might need to generalize it a bit more but it should show you the direction to go. E.g. it takes no care of possible whitespace. A … Read more
With all part optional with ?, you obtain one rule to rule them all : add_rewrite_rule( ‘^cities/(.*)/(browse)?/?(.*)?/?(.*)?/?(.*)?/?(.*)?/?’, ‘index.php?city_name=$matches[1]&cat_name[]=$matches[3]&cat_name[]=$matches[4]&cat_name[]=$matches[5]’, ‘top’ ); but the [] cannot work with the WordPress logic then you need to define the rewrite tag with a number. try that : add_rewrite_tag(“%cat_name.%”, “([^&]+)”); add_rewrite_rule( ‘^cities/([^/]*)/(browse)?/?([^/]*)?/?(^/)?/?([^/]*)?/?([^/]*)?/?’, ‘index.php?city_name=$matches[1]&cat_name1=$matches[3]&cat_name2=$matches[4]&cat_name3=$matches[5]’, ‘top’ );
The only thing more efficient code-wise than your Option 2 would be this one-liner: <?php $dom = str_replace( “https://wordpress.stackexchange.com/”, ”, get_blog_details()->path );
It’s called a path variable: Path variables enable us to add dynamic routes. See below example taken from the REST API handbook: // Here we are registering our route for single products. The (?P<id>[\d]+) is // our path variable for the ID, which, in this example, can only be some form // of positive number. … Read more
Note: this question is not related to WordPress, but rather to PHP directly and should be asked at StackOverflow but I have provided a very basic answer below to help you on your way. However be aware that this answer is not necessarily the best way to go about solving your problem, nor is it … Read more