Hi @msmiarowski
I hope you are doing good today.
I have made a test and BLC works fine with relative paths/links.
Does your /content-type/ is a custom post type? If so, could you navigate to Settings -> Link Checker -> Look for links in and mark your custom post type. For example, if your custom post type is “events” mark the “events” checkbox and save settings.
Let us know about the results.
Kind Regards,
Kris
Hi Kris,
Yes, it is a custom content type, and yes, I had the content type selected under Settings > Link Checker > Look For Links in. I also set it for published posts only. I have the settings selected for 3 custom content types, Pages, and Reusable Blocks.
I’m using WordPress 5.9, PHP v7.3, MySQL v8.0 as that is what my hosting provide has available for me. My local and dev/testing environment are set up the same, this is not a production site yet, but it will use the same versions I listed above.
More info: this is set up to be a headless WP, therefore WP is not building the UI. I am using this as just a CMS to manage our content and build REST API endpoints to query data for a few different apps/sites. This will be a central hub for content, so content authors only have to go to one CMS to update content. For that reason, in my functions.php I did force relative urls via this method:
add_filter(‘post_type_link’, ‘wp_make_link_relative’); // Custom post type urls
add_filter(‘page_link’, ‘wp_make_link_relative’); // Page urls
Best,
Matt
Hi @msmiarowski
Thank you for the update.
The broken link checker will loop on the posts and check the content from the database, so if the links are being changed on the front end only it is possible something is preventing the plugin.
Could you please send me an email to [email protected] using this template:
Subject: "Attn: Patrick Freitas"
Message: https://ww.wp.xz.cn/support/topic/relative-links-paths/
Best Regards
Patrick Freitas
Hi @msmiarowski
I hope you are doing well and safe!
We haven’t heard from you in a while, I’ll mark this thread as resolved.
Feel free to let us know if you have any additional questions or problems.
Best Regards
Patrick Freitas
Hi @wpmudevsupport12 (Patrick),
I apologize, for the delay, I had been rather ill for the last few weeks and haven’t been working much.
The original issue isn’t resolved and is still happening. It does not seem to be an issue with any plugin but rather the two lines of code in my functions.php file forcing the use of relative URLs
add_filter(‘post_type_link’, ‘wp_make_link_relative’); // Custom post type urls
add_filter(‘page_link’, ‘wp_make_link_relative’); // Page urls
When I disable these the plugin works as expected, however I only want our content managers to use relative URLs (for internal links). So forcing relative URLs is honestly the easiest way so they don’t have to think about it.
Hello @msmiarowski !
Our SLS team have suggested to wrap the filters in a check whether we’re running a cron task (which is how BLC works), so something like this:
if(!defined('DOING_CRON') && !DOING_CRON) {
add_filter('post_type_link', 'wp_make_link_relative'); // Custom post type urls
add_filter('page_link', 'wp_make_link_relative'); // Page urls
}
Best regards,
Pawel
@wpmudev-support9 thank you for the suggestion. I’ve tried the suggestion (in multiple ways) but it did not seem to work for what I needed. Maybe I’m not implementing it properly?
I also get this warning using the WP debugging option in the wp-config file:
Warning: Use of undefined constant DOING_CRON – assumed ‘DOING_CRON’ (this will throw an Error in a future version of PHP) in /app/wordpress/wp-content/themes/intranet-wp-theme/functions.php on line 50
Do you have any suggestions that may help me make sure I’m implementing this properly?
Thank you,
Matt
hi @msmiarowski,
I’m checking with our developer regarding this to see if there are any other workarounds, will keep you updated once we get further update.
However, you could also check whether using the wp_doing_ajax() function as mentioned in the following doc helps or not too:
https://developer.ww.wp.xz.cn/reference/functions/wp_doing_ajax/
Kind Regards,
Nithin