Skip Navigation

[Resolved] Custom post type ULR ost temporarily not working

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Waqar 3 months, 1 week ago.

Assisted by: Waqar.

Author
Posts
#2677309

I am writing to seek assistance with an issue we are experiencing on our WordPress Multisite, which uses Toolset for managing custom post types.

Issue Description:
We have been encountering intermittent 404 errors on certain pages of our multisite. Specifically, these errors seem to be related to the permalink structure, where the inclusion of "/blog" in the URLs is unexpected and inconsistent. This issue is sporadic but has been reported multiple times by our users, causing significant concern.

Steps Taken:
We have already taken several troubleshooting steps, including:

Checking the .htaccess file for any anomalies.
Resaving the permalink structure in WordPress settings.
Investigating potential conflicts with other plugins, particularly the Ultimate-Dashboard-Plugin.
However, these steps have not resolved the issue.

Toolset-Specific Inquiry:
We suspect that the issue might be related to the Toolset settings for our custom post types. We have not made recent changes to these settings, and they were previously functioning as expected. Could there be specific configurations within Toolset that might affect the permalink structure, especially in a multisite environment?

Request for Assistance:
We kindly request your guidance on how to address this issue. Are there known issues or specific settings within Toolset that we should examine? Any insights or suggestions would be greatly appreciated.

As the error does not show up regularly, I have recorded a video to show: hidden link

#2677391
Bildschirmfoto 2024-01-06 um 14.15.32.png

Hi, it happened again, and I have checked the Logfile, pls see Image, Before the permalink have changed, a cron job was running (but this often happens without any changes to the permalink structure).

<?php
/**
* A pseudo-cron daemon for scheduling WordPress tasks.
*
* WP-Cron is triggered when the site receives a visit. In the scenario
* where a site may not receive enough visits to execute scheduled tasks
* in a timely manner, this file can be called directly or via a server
* cron daemon for X number of times.
*
* Defining DISABLE_WP_CRON as true and calling this file directly are
* mutually exclusive and the latter does not rely on the former to work.
*
* The HTTP request to this file will not slow down the visitor who happens to
* visit when a scheduled cron event runs.
*
* @package WordPress
*/

ignore_user_abort( true );

if ( ! headers_sent() ) {
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
}

// Don't run cron until the request finishes, if possible.
if ( PHP_VERSION_ID >= 70016 && function_exists( 'fastcgi_finish_request' ) ) {
fastcgi_finish_request();
} elseif ( function_exists( 'litespeed_finish_request' ) ) {
litespeed_finish_request();
}

if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {
die();
}

/**
* Tell WordPress the cron task is running.
*
* @var bool
*/
define( 'DOING_CRON', true );

if ( ! defined( 'ABSPATH' ) ) {
/** Set up WordPress environment */
require_once __DIR__ . '/wp-load.php';
}

// Attempt to raise the PHP memory limit for cron event processing.
wp_raise_memory_limit( 'cron' );

/**
* Retrieves the cron lock.
*
* Returns the uncached `doing_cron` transient.
*
* @ignore
* @since 3.3.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @return string|int|false Value of the `doing_cron` transient, 0|false otherwise.
*/
function _get_cron_lock() {
global $wpdb;

$value = 0;
if ( wp_using_ext_object_cache() ) {
/*
* Skip local cache and force re-fetch of doing_cron transient
* in case another process updated the cache.
*/
$value = wp_cache_get( 'doing_cron', 'transient', true );
} else {
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", '_transient_doing_cron' ) );
if ( is_object( $row ) ) {
$value = $row->option_value;
}
}

return $value;
}

$crons = wp_get_ready_cron_jobs();
if ( empty( $crons ) ) {
die();
}

$gmt_time = microtime( true );

// The cron lock: a unix timestamp from when the cron was spawned.
$doing_cron_transient = get_transient( 'doing_cron' );

// Use global $doing_wp_cron lock, otherwise use the GET lock. If no lock, try to grab a new lock.
if ( empty( $doing_wp_cron ) ) {
if ( empty( $_GET['doing_wp_cron'] ) ) {
// Called from external script/job. Try setting a lock.
if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) {
return;
}
$doing_wp_cron = sprintf( '%.22F', microtime( true ) );
$doing_cron_transient = $doing_wp_cron;
set_transient( 'doing_cron', $doing_wp_cron );
} else {
$doing_wp_cron = $_GET['doing_wp_cron'];
}
}

/*
* The cron lock (a unix timestamp set when the cron was spawned),
* must match $doing_wp_cron (the "key").
*/
if ( $doing_cron_transient !== $doing_wp_cron ) {
return;
}

foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > $gmt_time ) {
break;
}

foreach ( $cronhooks as $hook => $keys ) {

foreach ( $keys as $k => $v ) {

$schedule = $v['schedule'];

if ( $schedule ) {
$result = wp_reschedule_event( $timestamp, $schedule, $hook, $v['args'], true );

if ( is_wp_error( $result ) ) {
error_log(
sprintf(
/* translators: 1: Hook name, 2: Error code, 3: Error message, 4: Event data. */
__( 'Cron reschedule event error for hook: %1$s, Error code: %2$s, Error message: %3$s, Data: %4$s' ),
$hook,
$result->get_error_code(),
$result->get_error_message(),
wp_json_encode( $v )
)
);

/**
* Fires when an error happens rescheduling a cron event.
*
* @since 6.1.0
*
* @param WP_Error $result The WP_Error object.
* @param string $hook Action hook to execute when the event is run.
* @param array $v Event data.
*/
do_action( 'cron_reschedule_event_error', $result, $hook, $v );
}
}

$result = wp_unschedule_event( $timestamp, $hook, $v['args'], true );

if ( is_wp_error( $result ) ) {
error_log(
sprintf(
/* translators: 1: Hook name, 2: Error code, 3: Error message, 4: Event data. */
__( 'Cron unschedule event error for hook: %1$s, Error code: %2$s, Error message: %3$s, Data: %4$s' ),
$hook,
$result->get_error_code(),
$result->get_error_message(),
wp_json_encode( $v )
)
);

/**
* Fires when an error happens unscheduling a cron event.
*
* @since 6.1.0
*
* @param WP_Error $result The WP_Error object.
* @param string $hook Action hook to execute when the event is run.
* @param array $v Event data.
*/
do_action( 'cron_unschedule_event_error', $result, $hook, $v );
}

/**
* Fires scheduled events.
*
* @ignore
* @since 2.1.0
*
* @param string $hook Name of the hook that was scheduled to be fired.
* @param array $args The arguments to be passed to the hook.
*/
do_action_ref_array( $hook, $v['args'] );

// If the hook ran too long and another cron process stole the lock, quit.
if ( _get_cron_lock() !== $doing_wp_cron ) {
return;
}
}
}
}

if ( _get_cron_lock() === $doing_wp_cron ) {
delete_transient( 'doing_cron' );
}

die();

#2677527

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

I've checked the custom post type's settings and the website's permalink settings, but couldn't find how the '/blog/' part was included in the URL.

Are you using any custom code or third-party plugin for the permalink settings or rewrite rules?

regards,
Waqar

#2677535
Bildschirmfoto 2024-01-08 um 09.44.26.png
Bildschirmfoto 2024-01-08 um 09.45.19.png

Hi Waqar,
thanks for your help!
I have the attached permalink structure, and A have tried different settings in Toolset, but all with the same effect, usually working and then from one moment to another 404, which persists, until I save either there permalink structure or the settings for the post type again.

Regards
Jutta

#2677602
Bildschirmfoto 2024-01-08 um 18.19.25.png

The cpt "projekte"-pages where down again, I have races Toolset settings without changes, it worked again, This is what the log file says:

#2677874

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

I've performed some tests on my multisite network website, but couldn't reproduce this behavior.

Also, even though I've looked into the settings of various active plugins on your website, it is still not clear exactly how the 'blog' part is getting included in the permalink settings, in the first place.
( screenshot: hidden link )

Have you added any code for this in the website's '.htaccess' file or the active child theme? If you're not aware of this, I'll need your permission to download a clone/snapshot of the website to investigate this on a different server.

#2678458
Bildschirmfoto 2024-01-15 um 11.09.52.png

Ho Waqar,

thanks for your help!
after three days without error we now had it again. See screenshot of log file. There is often a chronic-job running before.
I also do not know where the "Blog" comes from, but I am unable to change.
I would be glad if you create a code. How can I send you the ftp access?

this is the .htaccess, when the system ist running well:
# BEGIN WP Rocket v3.15
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>

# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>

# Since we’re sending far-future expires, we don’t need ETags for static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None

<IfModule mod_alias.c>
<FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$">
<IfModule mod_headers.c>
Header set X-Powered-By "WP Rocket/3.15"
Header unset Pragma
Header append Cache-Control "public"
Header unset Last-Modified
</IfModule>
</FilesMatch>

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
<IfModule mod_headers.c>
Header unset Pragma
Header append Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>

<IfModule mod_mime.c>
AddType image/avif avif
AddType image/avif-sequence avifs
</IfModule>
# Expires headers (for better cache control)
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# Feed
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 4 months"
ExpiresByType image/png "access plus 4 months"
ExpiresByType image/jpeg "access plus 4 months"
ExpiresByType image/webp "access plus 4 months"
ExpiresByType video/ogg "access plus 4 months"
ExpiresByType audio/ogg "access plus 4 months"
ExpiresByType video/mp4 "access plus 4 months"
ExpiresByType video/webm "access plus 4 months"
ExpiresByType image/avif "access plus 4 months"
ExpiresByType image/avif-sequence "access plus 4 months"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/ttf "access plus 4 months"
ExpiresByType font/otf "access plus 4 months"
ExpiresByType font/woff "access plus 4 months"
ExpiresByType font/woff2 "access plus 4 months"
ExpiresByType image/svg+xml "access plus 4 months"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
# Gzip compression
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don’t compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp|pdf)$ no-gzip dont-vary
</IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
<IfModule mod_headers.c>
Header append Vary: Accept-Encoding
</IfModule>
</IfModule>

# END WP Rocket

# BEGIN WordPress
# Die Anweisungen (Zeilen) zwischen „BEGIN WordPress“ und „END WordPress“ sind
# dynamisch generiert und sollten nur über WordPress-Filter geändert werden.
# Alle Änderungen an den Anweisungen zwischen diesen Markierungen werden überschrieben.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress

This is the .htaccess, with the error, think it is similar:
# BEGIN WP Rocket v3.15
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>

# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>

# Since we’re sending far-future expires, we don’t need ETags for static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None

<IfModule mod_alias.c>
<FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$">
<IfModule mod_headers.c>
Header set X-Powered-By "WP Rocket/3.15"
Header unset Pragma
Header append Cache-Control "public"
Header unset Last-Modified
</IfModule>
</FilesMatch>

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
<IfModule mod_headers.c>
Header unset Pragma
Header append Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>

<IfModule mod_mime.c>
AddType image/avif avif
AddType image/avif-sequence avifs
</IfModule>
# Expires headers (for better cache control)
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# Feed
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 4 months"
ExpiresByType image/png "access plus 4 months"
ExpiresByType image/jpeg "access plus 4 months"
ExpiresByType image/webp "access plus 4 months"
ExpiresByType video/ogg "access plus 4 months"
ExpiresByType audio/ogg "access plus 4 months"
ExpiresByType video/mp4 "access plus 4 months"
ExpiresByType video/webm "access plus 4 months"
ExpiresByType image/avif "access plus 4 months"
ExpiresByType image/avif-sequence "access plus 4 months"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/ttf "access plus 4 months"
ExpiresByType font/otf "access plus 4 months"
ExpiresByType font/woff "access plus 4 months"
ExpiresByType font/woff2 "access plus 4 months"
ExpiresByType image/svg+xml "access plus 4 months"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
# Gzip compression
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don’t compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp|pdf)$ no-gzip dont-vary
</IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
<IfModule mod_headers.c>
Header append Vary: Accept-Encoding
</IfModule>
</IfModule>

# END WP Rocket

# BEGIN WordPress
# Die Anweisungen (Zeilen) zwischen „BEGIN WordPress“ und „END WordPress“ sind
# dynamisch generiert und sollten nur über WordPress-Filter geändert werden.
# Alle Änderungen an den Anweisungen zwischen diesen Markierungen werden überschrieben.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress

#2678743

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I've performed some further troubleshooting and investigation, but I'm afraid, couldn't find any settings or code, that is responsible for this '/blog/' part in the permalink structure.

It could be something server/environment-related, but I'll need to download the website's duplicator package and test it on my server.

I'm setting your next reply as private so that you can share the FTP access details.

#2678770
#2678869

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I've downloaded the website's clone and will be performing some tests on this.

Will share the findings, as soon as this testing completes. Thank you for your patience.

#2679374

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Just wanted to let you know that I'm still working on this.

#2680390

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting, as I completed the testing on your website's clone.

I've tested your website's clone in a couple of different test environments, but couldn't reproduce this issue of the changing permalinks.

The 'blog' part from the permalink settings is removed, as soon as the 'Plain' option is selected and saved. And it doesn't come back, even if the old permalink option of 'Post name' is saved back again.

This suggests that something specific to your hosting or server environment is involved. I'll recommend raising this matter with the hosting support team to investigate these periodic changes in the permalink structure, for more insights.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.