How to change Post ID during import

wp_insert_post() function in WP accepts special import_id field in arguments and will try to use that ID, rather than automatically generating new one. This is easy to use when writing import code yourself, but I have no idea how easy would it be to with that plugin. You could try suggesting this as a feature … Read more

Custom Permalinks don’t work on local LAMP installation

I had the same problem. It sounds like you don’t have rewrites turned on in your installation. Find your httpd.conf file, find the following line: #LoadModule rewrite_module modules/mod_rewrite.so And remove the # at the beginning so it looks like this: LoadModule rewrite_module modules/mod_rewrite.so Save and then restart the service. Custom Permalinks should now work. There … Read more

Remove the Edit button in posts for permalinks on certain user roles? WP 3.3

You could do something like (in your functions.php file); if(current_user_can(‘member’)){ add_filter(‘get_sample_permalink_html’, ‘perm’, ”,4); function perm($return, $id, $new_title, $new_slug){ $post = get_post( $id ); if( ! $post || ( $post->post_type !== ‘testimonials’ ) ) { return $return; } return preg_replace( ‘/<span id=”edit-slug-buttons”>.*<\/span>|<span id=\’view-post-btn\’>.*<\/span>/i’, ”, $return ); } To give credit where credit is due, everything between … Read more

Get closest page ID from URL

You should be able to get the current url from $url = add_query_arg(). Then assuming, the structure: www.example.com/page/subpage/news/ID/post you can use preg_match to extract /page/subpage/news. Then it would be simple matter of using get_page_by_path();. If that fails you can then check /page/subpage/ and finally /page.

Confusion about how a URL is being parsed

WordPress uses set of regular expressions to parse urls (so called rewrite rules). It matches them in some order and stops when first matching rule is found. It’s a little bit hard to say what rule is matched in your case. We don’t know what are your permalink settings and what other changes to rewrite … Read more