get_pages with Custom Field Template plugin filling title attribute
-
I currently have the Custom Field Template plugin (https://www.ads-software.com/extend/plugins/custom-field-template/) installed, and have added a field to pages where the user can enter custom text which will appear in the title attribute of the menu anchor tags. Then (via jQuery) will be pulled into a fancier tooltip.
What I’m having trouble with is adding the custom field to my get_pages setup. I’m using this method: https://www.ads-software.com/support/topic/plugin-custom-field-template-insert-custom-code-into-a-template?replies=9 to allow me to put the custom field entries into my templates. It’s working fine when I add it in anywhere else on the page.
Below is my get_pages code, which is located in my header.php file (based on an example from the get_pages wiki page).
<?php $pages = get_pages(); foreach ( $pages as $pagg ) { $menuList = '<li><a href="' . get_page_link( $pagg->ID ) . '" title="' . getCustomField('Tooltip Text') . '">'; $menuList .= $pagg->post_title; $menuList .= '</a></li>'; echo $menuList; } ?>
With this setup, the custom field text is not appearing within the title attribute, but rather outside of the anchor tag and list tags all together. It also showing the custom field text for the current page in all instances, instead of the custom field text for each individual page (regardless of what the current page is).
If I delete
' . getCustomField('Tooltip Text') . '
and just enterTesting
instead, it display as expected (inside the title attribute, which jQuery moves to a tooltip).I’m a novice at PHP, so I have a feeling I’m missing something simple. At least, I hope it’s simple!
I appreciate any help.
- The topic ‘get_pages with Custom Field Template plugin filling title attribute’ is closed to new replies.