This seems more like a PHP programming question, but yes as you guessed in PHP if you want the value of a variable you just need $var
. echo $var
outputs it and will cause a syntax error how you’ve used it.
Otherwise everything else looks ok, although obviously I can’t say if that data structure will give you valid JSON-LD 😉
EDIT: Also it’s good to give your functions a more unique name than 'schema'
. You could call it 'yourname_jsonld_schema'
or something, so that it’s much more unique and unlikely to collide with any other names in WordPress
EDIT2: To address the extra error you added to your question, the place you define $schema
is inside an if
statement, which means that if the variable is not defined later, that if
was not true. So you need to do something like figure out why the if
is false, or if it’s correct, put the place where you use the $schema
inside the if
too.
Related Posts:
- Changing a specific value inside a complex repeater/flexible content field (ACF)
- ACF save json to custom directory not working, default acf-json used instead
- Trying to select 1 item from an array
- Strip comma from last element in concatenated JSON string
- How can you query posts by advance custom field when the value is a serialized array? [closed]
- ACF checkbox array is returning numbers, not labels [closed]
- Populating ACF Image Fields from JSON file
- Help using an array in ‘exclude’ key of another array
- Convert number to date format within an array
- Array sorting by custom field date
- Parsing value from Lottie JSON file
- Convert acf/gutenberg markup to html
- Filtering multiple custom fields with WP REST API 2
- Front end form to create a custom post with preview
- Generate a excerpt from an ACF-wysiwyg-field
- Pods cms and “advanced custom fields” plugin
- Adding a body class with ACF
- Returning all radio button options when using Advanced Custom Fields
- Order and group posts by acf by month and year
- Vimeo thumbnails [closed]
- Is there a way to export Advanced Custom Fields data?
- Advanced Custom Fields plugin : displaying a YouTube video
- WordPress Gutenberg, update post content programmatically
- How to add custom fields in rss feed
- Replace post’s “the_content” with ACF value
- PHP echo stripping formatting in Advanced Custom Fields [closed]
- How to upload multiple images on frontend to ACF gallery using update_field
- Add user custom fields and make editable on frontend
- Parsing php string in jquery [closed]
- Inconsistent behavior from number_format
- ACF custom block get_field() shows null on front-end? [closed]
- How to display genre of music content from one page to another page in wordpress
- Organize media library into folders and get folders via WP Rest API?
- ACF Update_field() update the field but changes are not seen in backend or rest api
- How to decrease the number of queries with get_posts and ACF?
- How to make Advanced Forms (and/or ACF) encode input value?
- ACF (Advanced Custom Fields) not updating post or postmeta values
- ACF Wysiwyg Editor Image srcset for responsive images [closed]
- Filter posts by advanced custom field
- User meta not saving properly
- Filtering from advance custom field data
- Insert Content into Script with Advanced Custom Fields
- How to use json_decode a post_meta value? [duplicate]
- Is there a better way of retrieving the name of an acf pagelink type from current post?
- Seemingly Simple Conditional Won’t Work?
- Prepared statements used incorrectly in ACF?
- Hide ACF from source code until a “show” button is clicked
- Pull info from Soundcloud embed into a custom field?
- How to disable field on Advanced Custom Fields? [closed]
- Outputing Post Object title as a div class with ACF
- Function wp_enqueue_style was called incorrectly
- Can you make a custom gutenberg block that allows the gutenberg editor within it?
- ACF Maps admin error: “For development purposes only” even after supplying api key
- Hash password field to database, unhash in admin?
- ACF google map not working [closed]
- Get a list of ACF Repeater-Fields as array
- Help using acf/save_post hook to connect to Untappd API and update_field [closed]
- Can’t add classes using jQuery from a JSON string with get_body_class()
- Get ACF fields in relationships of returned post
- Random images with no duplicates (ACF Gallery) [closed]
- Pulling in content from another page [closed]
- Advanced Custom Fields – Check multiple Empty Fields [closed]
- Simple Calendar
- ACF: If field contain a specific value, update value in another field
- Equation input with preview in classic editor
- Using the WP CLI to output the HTML results of calling a post?
- Sending simple variable on single page to WP JSON
- Can’t get the frontend cache to be deleted manually
- How to do a WP_Query when a post has a relationship to anoter post via an ACF Post Object field, where the related post is in a certain category?
- Custom ACF block only outputs commented JSON to the DOM
- WP get_posts meta_query using ACF repeater field
- get_posts filter meta_query using ACF Checkbox
- Is it okay to use an ACF field to store a password for a protected area of a page?
- Front End User Registration – How to Save ACF Values?
- Advanced Custom Fields | Help me link to a variable
- ACF Flexible Content with Bootstrap Carousel Repeater
- ACF don’t save the selected value
- ACF Pro Date Picker not coming through on Loop
- advanced custom fields if field has value show main div [closed]
- wp_split_shared_term_batch messing up upgraded ACF 5 data
- Creating a page from acf fields
- Populate ACF repeater with current structure of pages
- Use an image’s url as argument in update_field function
- Convert Custom Post Data to Javascript Array for Autocomplete
- Display a single row from nested array of custom field data
- display content in ascending order
- Add routes between multiple ACF google maps markers [closed]
- Hebrew WP 3.5: plugin activated, does not appear in sidebar [duplicate]
- How to share specific data contained in repeated fields across multiple pages
- Conditional Custom field with foreach
- Post Image alt text not appearing in WordPress website
- Adding custom field to an array
- ACF gives a syntaxError unexpected token
- meta_query for an ACF checkbox field don’t works correctly
- Using ACF on Posts Page
- Advanced custom fields if else statement
- Advanced custom fields and post types
- ACF gallery & bootstrap colls and rows [closed]
- Advanced Custom Fields – Issue with Slick Slider in ACF v6 Block
- How can I update an ACF field in a repeater on post save?