-
Notifications
You must be signed in to change notification settings - Fork 44
ACF error on archive and 404 pages. #114
Comments
@christianmagill Hmm, just want to make sure that you're on the latest version? |
@darrenjacoby Thanks for the quick response! Yes I am on 2.1.1, although the error also exists in 2.1.0. I updated in an effort to fix the issue to no avail. Running ACF 5.7.10 as well. |
@christianmagill does the error persist if you add an advanced custom field to a category/taxonomy? I haven't experienced this issue on 2.1.1, so any information to try recreate on my end would be helpful. |
@christianmagill following up here |
I'm able to duplicate this on the 404 page, but not on an archive page. The behavior I'm seeing on a 404 page seems to be completely an ACF bug, as I can replicate it on a stock WP 5.0.3 install w/ ACF 5.7.12 and the twentynineteen theme. Calling ACF's I'll file a bug report with ACF, but if you wanted to avoid this in controller, I would think a check for $query being false-y and then not running As to the issue occurring on a taxonomy/archive page, I haven't been able to replicate that either with controller or with a vanilla install. |
@darrenjacoby Sorry for the late reply, I've been off of the related project for a bit. The issue does not appear on category/taxonomy pages, but it does also appear on the front/index view when a page is not assigned. I'm also running into the same issue on a new project with fresh roots/sage installation. |
Replicated on 404 and on a CPT archives. Temporarily worked around it like this:
<?php
namespace App\Controllers;
use Sober\Controller\Controller;
class App extends Controller
{
protected $acf = false;
public function __construct()
{
if (acf_get_valid_post_id(get_queried_object())) {
$this->acf = true;
}
}
// ... My understanding is that
Controller passes Hope this helps towards a resolution! |
@mmirus I believe your work around while preventing the error, would also prevent acf option fields from being loaded as well. |
@christianmagill - I just noticed that what I'm seeing is not 100% the same as what you're experiencing. I'm not actually getting an error, just a warning, and my message traces back somewhere slightly different:
They do still seem to share some characteristics, though, and probably the same root cause. Looks like you're correct about my workaround dropping the options fields--good catch. If losing the options isn't an... option... for you, you can find an alternate approach (please share, if you do!) or downgrade to 2.1.0 until Darren has a chance to figure this out. I believe this was introduced in 2.1.1, so if you don't need the other changes in that update, you can just drop back a version for now. |
You might also be able to use my workaround and then just manually fetch the options in your controller with something like this: <?php
declare(strict_types=1);
namespace App\Controllers;
use Sober\Controller\Controller;
class App extends Controller
{
protected $acf = false;
public function __construct()
{
if (acf_get_valid_post_id(get_queried_object())) {
$this->acf = true;
}
}
public function acfOptions() : array
{
return get_fields('options') ?: [];
} |
Sorry everyone, I'll get this fixed as soon as I get a chance! Been swamped under last month so still catching up a little. |
No worries, take your time. Appreciate all the work you've put into Controller to make it such a useful tool for us. |
Pushed bee62f based on the above, not yet tagged but should remove the issue. (Little late I know) |
I'm receiving the following warning on archive and 404 pages.
The text was updated successfully, but these errors were encountered: