Site field set not working on 404

This topic is: not resolved
Viewing 10 posts - 1 through 10 (of 10 total)
Author Posts
February 17, 2016 at 2:31 am #3728
smartology
Post count: 5

Hi,
I am using a site field set in my header.php file, that is working fine for all pages apart from 404 pages.
e.g.
$wf->site->header->logo->url;

Do you have any suggestions to fix this?

February 17, 2016 at 10:05 am #3729
traversal
Post count: 207

Hi, just to clarify the approach, are you trying to use this code in a custom 404.php template?

Does the call to the site field set just not produce any results, or does the code error?

Thanks!

February 17, 2016 at 8:30 pm #3731
smartology
Post count: 5

Yes this is a custom 404 template.

So i have the logo loading like so
site->header->logo->url; ?>”>
and this does not produce a result,

but if i take it out of the src, the page will not load.

Cheers

February 19, 2016 at 12:17 pm #3733
traversal
Post count: 207

Hey, so I have found there’s a bug in the PHP unknown property methods which prevents something like this working when on a 404 page:

$wf->header->logo->url;

This assumes that your site field set is called “header”, and “logo” is the field name. The bug arises because of code that relies on the notion of a “current post”, which a 404 doesn’t have. (Will fix this).

If I place “site” in between, the code then picks up that you’re talking about the site object, and then can find the set from that. So for me this works:

$wf->site->header->logo->url;

Your code implies you’re already doing that, so that’s weird. Another thing you could try is this:

$wf->site->set(“header”)->logo->url;

Let me know if any of this helps!

February 19, 2016 at 9:24 pm #3734
smartology
Post count: 5

Hi, I was wondering if it had something to do with “current post”. it is very odd as i can get the logo to work on some 404 pages but not others.

404

I have tried set(“header”) but this stops the page from rendering, with error
PHP Fatal error: Call to a member function set() on a non-object.

Thanks again.

February 24, 2016 at 8:31 pm #3735
smartology
Post count: 5

Do you have an update on this issue?

February 24, 2016 at 9:30 pm #3736
traversal
Post count: 207

Hey, is this a multisite environment?

It seems like perhaps the site object isn’t defined either in some 404 pages, which I haven’t encountered before.

What do you get with the following code?

$wf->site->debug

Another thing to try:

$wf->site(1)->set(“header”)

Thanks!

February 24, 2016 at 10:22 pm #3737
smartology
Post count: 5

Hi,

No this is not a multisite.

Debug stops the page from rendering.
PHP Fatal error: Call to a member function debug() on a non-object

And site(1) stops the page from rendering.
PHP Fatal error: Call to a member function site() on a non-object

February 25, 2016 at 8:41 am #3738
traversal
Post count: 207

Hey there, seems like even the $wf entry-point variable is not defined. Can you try adding the following at the top of your template file?

global $wf;

February 25, 2016 at 8:00 pm #3739
smartology
Post count: 5

Cheers, that has fixed it.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Latest From the Blog

MasterPress 1.3.6 is now available

Masterpress 1.3.6 is a compatibility release. It resolves an edge case with shared fieldsets not working for MySQL 8 when the fieldset is limited to more than 1 post type or taxonomy or excluding any post types or taxonomies.

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the WordPress.com hosted service.

Three AM