How Do I Use a ACF Custom Field To Add A Slider ID?

soliloquy( the_field( 'slider' ) );

This is my code to add the ID for a slider from a ACF number field to a slider function call however it outputs the ID and doesn’t execute the soliloquy function.

I think it might have something to do with the single qoutes.

Not sure how to wrap the slider ID in single qoutes

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You need to use get_field() function instead. It will RETURN the value instead of printing.
So, your code will be:

soliloquy( get_field( 'slider' ) );

Method 2

This works but i prefer to use the ACF specific custom field function

soliloquy( get_post_meta( get_the_ID(), 'slider', true ) );


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x