Community Forums › Forums › Archived Forums › General Discussion › Putting custom field into footer area
Tagged: custom field footer, customise footer
- This topic has 5 replies, 2 voices, and was last updated 11 years ago by nutsandbolts.
-
AuthorPosts
-
November 19, 2013 at 11:25 am #74200TraceyRMember
Hi folks,
A custom field has been created that needs to be shown in the footer of a site I'm supporting, using Genesis and Lifestyle theme, but I can't get the PHP to work correctly in the functions.php file, where I customise the footer credits section
Existing code:
add_filter('genesis_footer_creds_text', 'custom_footer_creds_text');
function custom_footer_creds_text($creds) {
$creds = '<span style="font-size:12px;"> [footer_copyright] ' . get_bloginfo('name') . ' • Company Number 6358281 • All Rights Reserved • <br /> •
<span style="color: #e3e3e3;">PRIVACY POLICY</span> • </span> •
<span style="font-size:10px;">Website by: <span style="color: #e3e3e3;">The Simple Web Company</span> • <span style="color: #e3e3e3;"><?php wp_loginout(); ?></span></span>
';
return $creds;
}and just after the last " /span " I need to add this:
<?php echo $wp_query->queried_object->page-info ?>but it's not working - it shows part of the PHP code instead of the content of the "page info" custom field.
(This code was given to me by the guy who set up the custom field.)
I also tried this same code in the "Footer code section" of the main Genesis settings, and again it just shows "queried_object->page-info ?>" in the bottom left corner,
Has anyone had experience doing this?
thanks in hope
http://theleadershiptrainingworkshop.com/
TraceyNovember 19, 2013 at 1:19 pm #74217nutsandboltsMemberYou could create a shortcode to output the custom field. Something like this:
// Add shortcode for custom field function nabm_shortcode() { echo $wp_query->queried_object->page-info; } add_shortcode( 'pageinfo', 'nabm_shortcode' );
That would enable you to put
[pageinfo]
in the footer function instead of the PHP code. (Note: That's untested, so it may break if my syntax is incorrect. Which is very possible.)
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 20, 2013 at 3:26 am #74343TraceyRMemberThanks Andrea 🙂
Your code/syntax didn't break anything (phew), but it didn't output anything either, sadly...
I put your Shortcode function code before my footer code (of course), and then amended the end of the footer code :<span style="font-size:10px;">Website by: <span style="color: #e3e3e3;">The Simple Web Company</span> • <span style="color: #e3e3e3;"><?php wp_loginout(); ?></span></span>
<br />[pageinfo]
';
return $creds;
}But it's now not showing anything on the website...
If you have any other ideas, I'd love to hear them!
Thanks,
Tracey 🙂November 20, 2013 at 1:32 pm #74495nutsandboltsMemberTry this one and see if it outputs anything. Still trying to figure out exactly what the original PHP is calling so it may not work, either.
// Add shortcode for custom field function nabm_shortcode() { return $wp_query->queried_object->page-info; } add_shortcode( 'pageinfo', 'nabm_shortcode' );
Edited to add: What exactly is the custom field supposed to output?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+November 21, 2013 at 4:09 am #74684TraceyRMemberHi Andrea,
ah, thanks!! - it is now showing something - although not quite what I expected 🙂 It's just showing a "0" ...
The guy whose site it is (a friend), has an SEO expert who has set up a custom field to show keywords (yes, I know this isn't good practice at ALL - but it's not my website & my business!! I did try to convince him otherwise. Anyhow....)
The thing is, there are 4 custom fields per page, 3 set by various plugins (e.g. Sexybookmarks for social media sharing) but the 0 value being shown doesn't bear any relation to any of them - if I change the values, it still shows 0 - so it's almost like it's a binary value...
I'm going to get the SEO person to double-check that the statement "return $wp_query->queried_object->page-info;" does actually do what he intends, as with your help we have something showing...
Thank you kindly!!!
TraceyNovember 21, 2013 at 5:40 pm #74809nutsandboltsMemberIf you show him what we're trying to do, he might be able to help you tweak the function for the shortcode. It's hard to know exactly how to word it without seeing how the custom field is set up.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+ -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.