Rewrite custom post type url’s adding meta box values

It sounds like you’re very close here and your only remaining issue is that your permalinks for genres and movies collide. ‘movies’ CPT permalink /genres/%custom field meta box value%/%movie%/ ‘genres’ CPT permalink /genres/%genre%/ The issue here is using the add_permastruct. When it creates the rules for movies, they look something like this: genres/([^/]+)/([^/]+)(/[0-9]+)?/?$ => index.php?genre=$matches[1]&movies=$matches[2]&page=$matches[3] … Read more

How to add .htaccess code through a function?

/** * Inserts an array of strings into a file (.htaccess ), placing it between * BEGIN and END markers. Replaces existing marked info. Retains surrounding * data. Creates file if none exists. * * @param array|string $insertion * @return bool True on write success, false on failure. */ function add_htaccess($insertion) { $htaccess_file = ABSPATH.’.htaccess’; … Read more

Rewrite rules goes away

properties_add_rewrite_rules should be hooked to init so it runs on every request. Rules can be flushed at any time- loading the permalinks settings page calls flush_rewrite_rules, and your rules weren’t added on that request, so they disappear.

How to check if last uri segment is a custom post type or taxonomy term?

To see how we can make this work, have a read through the Query Overview Codex page, particularly the What Plugins can Modify section: Modify the query specification, after variable values are saved (request filter or parse_request action; if you want to use conditional tag tests, use the parse_query or pre_get_posts action, as these run … Read more

WordPress in “Couch Mode”?

Here’s a method to achieve what you want internally without adding anything to the .htaccess file. It works by adding a rewrite endpoint named read, so any single post permalink with read appended to the end will have a different single post template applied. For example, if your normal single post permalink is: localhost/techylab/some-post-title/ The … Read more

Custom comments

$args = array(‘post_id’=>get_the_ID(), ‘status’=> ‘approve’); $all_comm = get_comments($args); $per_page = get_option(“comments_per_page”); if(!$per_page) $per_page = 4; $cpage = get_query_var(“cpage”); if(!$cpage) $cpage = 1; if(round(count($all_comm)/$per_page) == 0) $total = 1; else $total = round(count($all_comm)/$per_page); $args_comments = array( ‘base’ => add_query_arg( ‘cpage’, ‘%#%’ ), ‘format’ => “”, ‘total’ => $total, ‘current’ => $cpage, ‘echo’ => false, ‘add_fragment’ => … Read more

WordPress Network on IIS7/SQL Server – Rewrite Issues

This sounds like your domain doesn’t match the cookie being generated. It may not have anything to do with the IP. define( ‘DOMAIN_CURRENT_SITE’, ‘svr-web-csrms’ ); I would expect an actual domain or something, like this. define( ‘DOMAIN_CURRENT_SITE’, ‘subdomain.mysite.tld’ ); I tried to look at your web.config – but it appears that the URL is now … Read more