Many Rewrite Parameters/Rules

The pattern (.+) matches any character, including the slash, so any combo of parameters will always match your first rule, with anything that follows being passed as the version query var. Change all instances of (.+) to ([^/]+) to match all characters except the slash.

Rewrite Most WordPress URLs

I think htaccess would be fastest way. Overhead of checking 50 simple regexp is very small – page generation is several orders of magnitude slower so you shouldn’t care about it. This wont hit performance, you can set rewrite only for domain mysite.com and it won’t check rules for tech.mysite.com reducing overhead, which isn’t noticeable … Read more

How to get image URL from media_sideload_image?

Try the fourth input parameter (available in 4.2+): @param string $return Optional. Accepts ‘html’ (image tag html) or “https://wordpress.stackexchange.com/questions/212512/src” (URL). Default ‘html’. So change your code snippet to: $new_image_url = media_sideload_image($new_url, $post_ID, $title, $src=”https://wordpress.stackexchange.com/questions/212512/src” ); to get the src instead of the default html. Note that the output might also be an WP_Error object for … Read more

get_template_directory() returns wrong address on VPS

You can read data on your server with file_get_contents(). If you want to make sure the file exists and is readable then use is_readable(). You don’t really need to use trailingslashit() in this case because you’re constructing the URI yourself. // path to file under current theme $json_file = get_template_directory() . ‘/inc/includes/acf-fonticonpicker/icons/selection.json’; // make sure … Read more

Pass form input via url variable

The first form: <form method=”post” action=”some-url.php”> <input type=”email” placeholder=”Email address” value=”” name=”email”> <input type=”submit” value=”Submit” name=”email-submit”> </form> Then in some-url.php: if( isset($_POST[’email’] ) $email = $_POST[’email’] The post method would be preferred here since it won’t create server log entries that include the user’s email address. You should also do this over SSL since you … Read more

How to remove /page/2/ from home page?

If the front page is set to display posts then the query for those posts will run regardless of wether your theme shows these posts or not. That’s why you’re getting pagination with no posts. You can test this by temporarily removing your themes front-page.php (or whatever it is). You should see all your posts … Read more

Problem with images URL after filter applying

<?php $string = ‘Sentence 1. Sentence 2? Sentence 3! Sentence 4… Sentence 5… Sentence 6! Sentence 7. Sentence 8. Sentence 9… Sentence 10… Sentence 11. ‘; $sentences_per_paragraph = 3; // settings $pattern = ‘~(?<=[.?!…])\s+~’; // some punctuation and trailing space(s) $sentences_array = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY); // get sentences into array $sentences_count = count($sentences_array); // … Read more

Change permalinks for specific pages

You can only have one page at example.com so let’s say you have an ‘about’ page: example.com/about In WordPress Settings > Reading Settings you can select a static page to be the homepage, so example.com would now show the ‘about’ page. Now, go to WordPress Settings > Permalinks and select Post name.

how to replace hostnames on certain external links?

If the links are coming from the main content areas, you could create a hook which acts against this “content” output. In your themes functions.php file, you could try something like: add_filter(‘the_content’, ‘the_url_filter_function_name’, 30); function the_url_filter_function_name($content) { return str_replace(‘bad-url.com’, ‘good-url.com’, $content); } If the URLs you are looking to modify are being stored and output’d … Read more