Adding a URL Parameter to JPEG images in posts

function add_jpeg_params($content){ preg_match_all(“/https?:\/\/[^\/\s]+\/\S+\.(jpg|jpeg)/”, $content, $output_array); $items_to_replace = array_unique($output_array[0]); $items_to_replace = array_values($items_to_replace); for ($j = 0; $j < sizeof($items_to_replace); $j++) { $content = str_replace($items_to_replace[$j], $items_to_replace[$j] . ‘?t=” . time(), $content); } return $content; } add_filter(“the_content’,’add_jpeg_params’,10); add_filter(‘post_thumbnail_html’, ‘add_jpeg_params’ );

Which url points to which file

WordPress has a template hierarchy, he search down the files in your theme until he finds a suitable template for the content hes outputing following the hierarchy. Here it’s a example from de Codex: If your blog is at http://example.com/blog/ and a visitor clicks on a link to a category page such as http://example.com/blog/category/your-cat/, WordPress … Read more

Rewrite URL to get rid of wp-content etc and change URL

$matches[1] doesn’t work for external redirects, only internal (URL must start with index.php and handled by WordPress itself) Try this add_action(‘init’, ‘custom_rewrite_pdfURL’); function custom_rewrite_pdfURL() { add_rewrite_rule(‘^carPDF/([^/]*)/?’, ‘wp-content/themes/exampletheme/templates/pdf-generator.php?productID=$1’, ‘top’); } Don’t forget to flush permalinks

Post url rewriting for posts with certain category

generate_rewrite_rules didn’t work for me at all and I found posts on forums where others were having the same issue. Adding to the rewrite_rules_array did work. Below is the solution. add_filter( ‘post_link’, ‘custom_permalink’, 10, 3 ); add_filter(‘rewrite_rules_array’,’wp_insertMyRewriteRules’); add_filter(‘init’,’flushRules’); function custom_permalink( $permalink, $post, $leavename ) { $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->cat_name == “Shop” … Read more