Custom rewrite rules for /pastissues/%category%-%postname%.html

Or, you can do that – after headhache and spent one day to find a solution : You have to set ‘rewrite’ => false in your register_post_type(); and add after closing register_post_type() : // 404 CPT permalink WP bug… global $wp_rewrite; $projet_structure=”/projets/%projet%”; $wp_rewrite->add_rewrite_tag(“%projet%”, ‘([^/]+)’, “projet=”); $wp_rewrite->add_permastruct(‘projet’, $projet_structure, false); Where projet is my CPT See here … Read more

Advanced permalinks structure

WordPress is practically setup to support this out of the box. You can go to mysite.com/?category_name=news&tag=sports to see the magic happen. All we need to do here is match a permalink structure to this existing URI, and WP makes this unreasonably easy. In your theme’s functions.php file, add: add_action( ‘init’, ‘wpse_88059_add_rewrites’ ); function wpse_88059_add_rewrites() { … Read more

Link post images to post

Yes, don’t use regex for parsing HTML but use DOM instead. This is how I would work it out : In your toolbox, a function to get innerDOM of a node : // GET INNER HTML OF A NODE function DOMinnerHTML($element) { $innerHTML = “”; $children = $element->childNodes; foreach ($children as $child) { $tmp_dom = … Read more

Customizing a permalink

try this: <h2 class=”featured-title”><a href=”http://siteurl.com/category/<?php echo strtolower(str_replace(” “,””,$arr[$i][“title”])); ?>”><?php echo esc_html($arr[$i][“title”]); ?></a></h2>

What is the simplest way to create a redirect

When you register your custom post type, set the has_archive argument to the slug you want for the archive page, in this case drinks: $args = array( ‘rewrite’ => array( ‘slug’ => ‘drink’ ), ‘has_archive’ => ‘drinks’, );