Ken Stone
Forum Replies Created
-
Forum: Networking WordPress
In reply to: How to add WWW to one of the domain of my multisitewhen we search for example.fr, the global page appears but it should be the french page
Do you mean searching on a site like dogpile or google?
Forum: Fixing WordPress
In reply to: When do we need to make new plugins?I tell people that you create a new plugin when you want to add new functionality.
Forum: Fixing WordPress
In reply to: Beginner help with paginationThere are some examples here https://codex.www.ads-software.com/Function_Reference/get_query_var#Examples in the codex on the use of get_query_var.
Forum: Fixing WordPress
In reply to: Layered User LoginsInstead of multiple logins for each I would try to use WordPress roles and capabilities. One login then assign roles/capabilities to users to access each area.
Courses can have rosters with existing users assigned to allow access.
Forum: Developing with WordPress
In reply to: update_post_meta update more than one post metaWait what? I use update_post_meta quite a bit. What is meant by i’ts next adjacent one’? Are you saying that a post other than the post id passed to update_post_meta is being updated or are you saying that an entry in the same post id with the same key name is also being updated?
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateOK I just revisited this one tried using the slug by adding
'rewrite' => array('slug' => $thinkific_rewrite),
to the CPT. Then deleted all the code for creating rewrite rules.Also using
$this->loader->add_filter('single_template', $plugin_public, 'stoneblue_thinkific_single_template'); $this->loader->add_filter('archive_template', $plugin_public, 'stoneblue_thinkific_archive_template');
for the cpt templates.
Mission accomplished.
Thanks!
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateThanks bcworkz and lannister,
I could have made it easy on myself and just named the CPT online-courses. This is a single site. I turned what should have been a few hour project into a few days but the learning experience is priceless.
Yes all the back end links seem to be covered by
post_type_link
hook but more testing will be needed to determine this. And at this point I believe there aren’t any stoneblue-thinkific links remaining. Putting the names I’m sure that will be used directly in the CPT surely would have been the way to go and could still be. I will investigate the rewrite slug further.I guess the reason I decided to give the direct manipulation of the rules array a try is because I saw just how many rules are created for the CPT and thought wow might as well just copy these.
I’ve used add_rewrite_rule successfully in the past for things other than CPTs so I’m sure that especially equipped with my new mastery of regexs I’d be able to get this working in no time at this point. TBH I wasn’t quite sure where exactly to redirect to but now seeing everything clearly in the rules array it’s a bit of a no brainer.
Yes I’m flushing only on act and deact. I believe it’s recommended to rewrite the rules on
init
just because of you never know what other plugins are doing but I could be wrong on that.This is a great book by jfriedl on regex, highly recommend it to everyone no doubt. I’m sure I will get carried away initially…
I was having difficulty with single_template I think it was because I was failing to visit the perma links page or flush the rules. The code for it is still in but the add_filter is commented out currently.
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateI’m on the fence about maintaining the old CPT name rules (stoneblue-thinkific) in the rules array.
thoughts?
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateApparently order matters in the rules array.
Changed the code to:
public function rewrite_rules_array($rules){ $options = get_option($this->plugin_name); $thinkific_rewrite = $options['thinkific_rewrite']; foreach($rules as $rule => $replace){ if(preg_match('/^stoneblue-thinkific/', $rule) == 1){ $newrule = preg_replace('/^stoneblue-thinkific/', $thinkific_rewrite, $rule) $rrules[$newrule] = $replace; } $rrules[$rule] = $replace; } return $rrules; }
Which produces a new rules array:
rules: array ( '^wp-json/?$' => 'index.php?rest_route=/', '^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]', '^index.php/wp-json/?$' => 'index.php?rest_route=/', '^index.php/wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]', 'online-courses/?$' => 'index.php?post_type=stoneblue-thinkific', 'stoneblue-thinkific/?$' => 'index.php?post_type=stoneblue-thinkific', 'online-courses/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'stoneblue-thinkific/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'online-courses/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'stoneblue-thinkific/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'online-courses/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]', 'stoneblue-thinkific/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]', 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 'category/(.+?)/embed/?$' => 'index.php?category_name=$matches[1]&embed=true', 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', 'tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 'tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 'tag/([^/]+)/embed/?$' => 'index.php?tag=$matches[1]&embed=true', 'tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', 'tag/([^/]+)/?$' => 'index.php?tag=$matches[1]', 'type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]', 'type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]', 'type/([^/]+)/embed/?$' => 'index.php?post_format=$matches[1]&embed=true', 'type/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?post_format=$matches[1]&paged=$matches[2]', 'type/([^/]+)/?$' => 'index.php?post_format=$matches[1]', 'online-courses/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'online-courses/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'online-courses/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'online-courses/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'online-courses/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true', 'stoneblue-thinkific/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true', 'online-courses/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1', 'stoneblue-thinkific/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1', 'online-courses/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'online-courses/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'online-courses/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]', 'stoneblue-thinkific/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]', 'online-courses/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]', 'online-courses/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]', 'stoneblue-thinkific/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]', 'online-courses/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'stoneblue-thinkific/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'online-courses/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'stoneblue-thinkific/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'online-courses/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'online-courses/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'stoneblue-thinkific/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'robots\\.txt$' => 'index.php?robots=1', '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\\.php$' => 'index.php?feed=old', '.*wp-app\\.php(/.*)?$' => 'index.php?error=403', '.*wp-register.php$' => 'index.php?register=true', 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', 'embed/?$' => 'index.php?&embed=true', 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', 'comments/embed/?$' => 'index.php?&embed=true', 'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', 'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', 'search/(.+)/embed/?$' => 'index.php?s=$matches[1]&embed=true', 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', 'search/(.+)/?$' => 'index.php?s=$matches[1]', 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', 'author/([^/]+)/embed/?$' => 'index.php?author_name=$matches[1]&embed=true', 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', '([0-9]{4})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&embed=true', '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]', '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', '([0-9]{4})/embed/?$' => 'index.php?year=$matches[1]&embed=true', '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', '([0-9]{4})/?$' => 'index.php?year=$matches[1]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&paged=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&cpage=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]', '([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]', '([0-9]{4})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&cpage=$matches[2]', '.?.+?/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', '.?.+?/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', '.?.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '.?.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '.?.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', '.?.+?/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', '(.?.+?)/embed/?$' => 'index.php?pagename=$matches[1]&embed=true', '(.?.+?)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1', '(.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]', '(.?.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]', '(.?.+?)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]', '(.?.+?)/comment-page-([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&cpage=$matches[2]', '(.?.+?)(?:/([0-9]+))?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]', )
Going to walk to the dog now and move on to the next task finally!!!
Thanks for your help!!!
Really appreciate it !!!
Enjoy today !!!
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateSo I really thought I was finished after adding the new rules to the rules array with this being the new rules array (some items deleted for brevity).
rules: array ( 'stoneblue-thinkific/?$' => 'index.php?post_type=stoneblue-thinkific', 'stoneblue-thinkific/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'stoneblue-thinkific/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'stoneblue-thinkific/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'stoneblue-thinkific/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true', 'stoneblue-thinkific/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1', 'stoneblue-thinkific/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]', 'stoneblue-thinkific/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'stoneblue-thinkific/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'stoneblue-thinkific/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'online-courses/?$' => 'index.php?post_type=stoneblue-thinkific', 'online-courses/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'online-courses/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'online-courses/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]', 'online-courses/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'online-courses/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'online-courses/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'online-courses/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'online-courses/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true', 'online-courses/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1', 'online-courses/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'online-courses/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'online-courses/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]', 'online-courses/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]', 'online-courses/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]', 'online-courses/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'online-courses/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'online-courses/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'online-courses/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'online-courses/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', )
using this code:
public function rewrite_rules_array($rules){ $options = get_option($this->plugin_name); $thinkific_rewrite = $options['thinkific_rewrite']; foreach($rules as $rule => $replace){ if(preg_match('/^stoneblue-thinkific/', $rule) == 1){ $newrule = preg_replace('/^stoneblue-thinkific/', $thinkific_rewrite, $rule); $rules[$newrule] = $replace; } } return $rules; }
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateWhat if I used the rules array and copied the entries with the CPT name at the beginning of the rule and replaced the CPT name with the name the user configures then pushed those back onto the rules array?
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateflush_rewrite_rules
is being called onactivate
anddeactivate
andrewrite
oninit
. I saw somewhere that adding the rewrite in the activate just before the flush is a good idea but I don’t understand why.I finally took the plunge and purchased jfriedl’s Mastering Regular
Expressions. I’m on my way…Thank you very much for the regex. I’m going to give these a try and with my new understanding of regex maybe today is the day this gets completed.
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateEven though the rewrite rule may not be the correct one it should still be in the rules array?
rules: array ( '^wp-json/?$' => 'index.php?rest_route=/', '^wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]', '^index.php/wp-json/?$' => 'index.php?rest_route=/', '^index.php/wp-json/(.*)?' => 'index.php?rest_route=/$matches[1]', 'stoneblue-thinkific/?$' => 'index.php?post_type=stoneblue-thinkific', 'stoneblue-thinkific/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'stoneblue-thinkific/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=stoneblue-thinkific&feed=$matches[1]', 'stoneblue-thinkific/page/([0-9]{1,})/?$' => 'index.php?post_type=stoneblue-thinkific&paged=$matches[1]', 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 'category/(.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', 'category/(.+?)/embed/?$' => 'index.php?category_name=$matches[1]&embed=true', 'category/(.+?)/page/?([0-9]{1,})/?$' => 'index.php?category_name=$matches[1]&paged=$matches[2]', 'category/(.+?)/?$' => 'index.php?category_name=$matches[1]', 'tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 'tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?tag=$matches[1]&feed=$matches[2]', 'tag/([^/]+)/embed/?$' => 'index.php?tag=$matches[1]&embed=true', 'tag/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?tag=$matches[1]&paged=$matches[2]', 'tag/([^/]+)/?$' => 'index.php?tag=$matches[1]', 'type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]', 'type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_format=$matches[1]&feed=$matches[2]', 'type/([^/]+)/embed/?$' => 'index.php?post_format=$matches[1]&embed=true', 'type/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?post_format=$matches[1]&paged=$matches[2]', 'type/([^/]+)/?$' => 'index.php?post_format=$matches[1]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'stoneblue-thinkific/([^/]+)/embed/?$' => 'index.php?stoneblue-thinkific=$matches[1]&embed=true', 'stoneblue-thinkific/([^/]+)/trackback/?$' => 'index.php?stoneblue-thinkific=$matches[1]&tb=1', 'stoneblue-thinkific/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?stoneblue-thinkific=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&paged=$matches[2]', 'stoneblue-thinkific/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?stoneblue-thinkific=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?stoneblue-thinkific=$matches[1]&page=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', 'stoneblue-thinkific/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', 'stoneblue-thinkific/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', 'stoneblue-thinkific/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', 'robots\\.txt$' => 'index.php?robots=1', '.*wp-(atom|rdf|rss|rss2|feed|commentsrss2)\\.php$' => 'index.php?feed=old', '.*wp-app\\.php(/.*)?$' => 'index.php?error=403', '.*wp-register.php$' => 'index.php?register=true', 'feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', '(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]', 'embed/?$' => 'index.php?&embed=true', 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]', 'comments/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', 'comments/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?&feed=$matches[1]&withcomments=1', 'comments/embed/?$' => 'index.php?&embed=true', 'search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', 'search/(.+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?s=$matches[1]&feed=$matches[2]', 'search/(.+)/embed/?$' => 'index.php?s=$matches[1]&embed=true', 'search/(.+)/page/?([0-9]{1,})/?$' => 'index.php?s=$matches[1]&paged=$matches[2]', 'search/(.+)/?$' => 'index.php?s=$matches[1]', 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]', 'author/([^/]+)/embed/?$' => 'index.php?author_name=$matches[1]&embed=true', 'author/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&paged=$matches[2]', 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]', '([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', '([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]', '([0-9]{4})/([0-9]{1,2})/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&embed=true', '([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]', '([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]', '([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', '([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&feed=$matches[2]', '([0-9]{4})/embed/?$' => 'index.php?year=$matches[1]&embed=true', '([0-9]{4})/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&paged=$matches[2]', '([0-9]{4})/?$' => 'index.php?year=$matches[1]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/embed/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&paged=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&cpage=$matches[5]', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(?:/([0-9]+))?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', '([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]', '([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]', '([0-9]{4})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&cpage=$matches[2]', '.?.+?/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]', '.?.+?/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1', '.?.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '.?.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]', '.?.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]', '.?.+?/attachment/([^/]+)/embed/?$' => 'index.php?attachment=$matches[1]&embed=true', '(.?.+?)/embed/?$' => 'index.php?pagename=$matches[1]&embed=true', '(.?.+?)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1', '(.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]', '(.?.+?)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]', '(.?.+?)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]', '(.?.+?)/comment-page-([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&cpage=$matches[2]', '(.?.+?)(?:/([0-9]+))?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]', )
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateI’m now using the
post_type_link
hook to modify the links which is really cool but theadd_rewrite_rule
still has me a bit baffled. I’ll go walk the dog now and see if that helps..public function rewrite(){ $options = get_option($this->plugin_name); $thinkific_rewrite = $options['thinkific_rewrite']; add_rewrite_rule($thinkific_rewrite . '/?([^/]*)', '/index.php?post_type=stoneblue-thinkific&name=$matches[1]', 'top'); }
- This reply was modified 6 years, 7 months ago by Ken Stone.
Forum: Developing with WordPress
In reply to: add_filter(single-{CPT}_templateNow I want to provide the user the ability to choose the link structure for the CPT.
So instead of having //websitecom/stoneblue-thinkific/basket-weaving-101 I’d like the stoneblue-thinkifici portion to be a plugin setting.
So I’m looking to the rewrite rules for this. What I have so far is sort of working.
If I set base_url in the options table to ‘online-courses’ then I’m able to navigate to //webaddresscom/online-courses/basket-weaving-101 but //webaddresscom/online-courses (the archive) only works if the previous page was the single (basket weaving) page.public function rewrite(){ $options = get_option($plugin_name); $base_url = $options['base_url']; add_rewrite_rule($base_url . '/?([^/]*)', '/index.php?post_type=stoneblue-thinkific/', 'top'); add_rewrite_tag( '%course%', '([^/]+)' ); add_permastruct( 'course', $base_url . '/%course%' ); }