I am currently trying to add an additional input field where users are able to specify an aria-label inside the already existing link field within Advanced Custom Fields in Wordpress. I’ve attached an image to give a visual representation of what I am looking to do.
Link Modal
Then on the frontend you would use something like $link[aria-label] to get it from the link array.
Any help to achieve this would be amazing. Thank you!
You can try if that field already exists in the ACF link.
Store that link value in a variable and print_r it and check. Check the below code.
<?php
$link = get_field('YOUR-FIELD-NAME');
print_r($link);
?>
Related
I'm building a website in WordPress using the Advanced Custom Fields plugin alongside metaslider, I want the user to be able to select a metaslider from a dropdown list by using a custom field.
I know that you can add a slider in via the WYSIWYG however I want to make a seamless way of doing this, it's probably not as simple as I'd like it to be.
The website consists of projects and will have several sliders all will be appropriately named and I want to make it foolproof for the user.
I've searched online and can't seem to find anyone else who has wanted/tried to to this.
Ask an questions you have if i haven't been clear!
Any help would be greatly appreciated.
It's okay, I figured out how to do it!
You can select a field type of "post object" then add a "post type" of Meta Slider then the user has a dropdown box where they can select which slider they want to display on the page.
Metaslider shortcode id in ACF:
$slider_object['value']->ID
Try:
<?php $slider = get_field_object('slider_item'); ?>
<?php echo do_shortcode('[metaslider id="'.$slider['value']->ID.'"]'); ?>
I am using magic field plugin for my project and created two related type fields and I want to get selected post/page id. Please help me I am stuck here.
Inside the loop you can say:
<?php echo get('field_name') ?>
Replace field_name with the name of your field. This should print it's contents.
I have a Text Field added to a Content Type and I want to add a PayPal button in this field.
When I display the page, it shows the HTML in its entirety... rather than just the button.
Anyone know a work around or an override for this formatting?
Thx in advance :)
You need to create a template file and rewrite the html and php. For example the file will be called field--field_pay_pal.tpl.php (or whatever the machine name is) and and you will access the value using the $label value. It may be in an associative array so to check the value use the dpm($label) to get the values. Here is some more information below on the reference
http://api.drupal.org/api/drupal/modules!field!theme!field.tpl.php/7
An example would be
<img src="<?php print $label[0][value]; ?>" />
I have several custom content types and in one specific one I need to offer two fields, one for the href for a link, and one for the text of a link this way I can build and style it with minimal user involvement of the HTML/CSS. I also have a custom node.tpl for this content type. My problem is that drupal throws divs around each field I create that aren't in my template file for this content type (node-custom.tpl) and I can't put the href for a link with divs around it inside google.co.uk</div>"> See my problem. Maybe I'm doing this all wrong so any other ideas are welcome.
Please note I'm trying to create this site with minimum involvement of HTML/CSS access for the user. I'm aware I could hand code the link in the field.
The easiest way to do this would be to use a preprocess function in your template.php file and build the link up manually:
function mytheme_preprocess_node(&$vars) {
$node = $vars['node'];
if ($node->type = 'my_type') {
$uri = $node->field_name_of_link_field[LANGUAGE_NONE][0]['value'];
$text = $node->field_name_of_display_text_field[LANGUAGE_NONE][0]['value'];
$vars['my_link'] = l($text, $uri); // Using Drupal's l() function to render a link
}
}
Then in your node template file you'll have access to the variable $my_link which you can output anywhere, and will contain the correct HTML for the link. Finally, go to the "Manage Display" page for your content type and set the display of the two fields you no longer need to output to 'Hidden'.
There are other ways so if that's no good let me know
EDIT
Just to add, I think the easiest way to do this would actually be to install the Link module and use the provided field type instead of the two other fields you're currently using.
I can't seem to figure out how to display (echo) a custom field I added to user profiles(via people > account settings > manage fields).
I added a text field called team (field_team). I then clicked manage display and displayed it. It then shows up under there profile page. Great!
However, now I will like to also display that on the frontpage and in the node view as well. How, or where do I do that?
EDIT: I ended up finding this article and this works. http://drupal.org/node/1194506
Code used:
<?php
$node_author = user_load($node->uid);
print ($node_author->roles[3]);
print ($node_author->field_biography['und'][0]['value']);
?>
You must enable devel module to try this:
global $user;
dpm($user);
Hope that helps revealing the new field.