It looks like the problem is with your IF statement.
if($post->ID = 142)
should be if($post->ID == 142)
(notice the 2 equals signs)
Otherwise you are just resetting the variable $post->ID to 142
Related Posts:
- Advanced Custom Fields dynamic update_field
- Load one page with parent and child pages
- How to use page metadata while using wp_list_pages()?
- How to enable custom fields for pages (if not a bad practice)?
- Advanced Custom Fields – Get custom fields from parent page
- How to add add_meta_box to specific Page Template?
- Having different sidebar content for MANY pages?
- Custom Page Template [closed]
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- Add input field to ‘Pages > Edit Page’ through functions.php
- Deleted pages showing up when querying for child pages
- Calling custom fields for pages (not posts)
- How to Display pages with a Custom Fields in one page
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- List child pages by slug not ID?
- Display the contents of a custom field of a page on their child
- Combining ‘depth’ with ‘include’ in wp_list_pages()
- get_post_meta() retrieves meta from a specific post on pages, not the page currently viewed
- How to pass page as an argument like post in WordPress?
- How to display childrens custom fields?
- How can I use custom properties to set different background on different pages?
- Displaying pages with a specific custom meta
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- Sort and display pages with specific custom field (not tag)
- Dynamic menu wp_list_pages displaying only current branch including: current page, his siblings and its childs
- Is there a way to dump all registered sidebar/widget?
- Display a different image for each page with editor
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- Check if page has subpages
- Display the output from Custom User Fields from a WordPress user profile on a WordPress Custom Page
- Page template is missing fields or is invalid when I updating the template
- Display Child Page with custom fields within Parent Page
- Custom Field select list is truncated
- Getting content from custom fields of different pages on a single page
- Decouple page name from page title
- Get current post’s child page?
- How to make in post Parent page children page list nummbered
- How do delete a meta key?
- Attaching Metadata to a Taxonomy Item
- Save Custom Fields for Variations Product
- Archive sorting functions by custom fields (front-end)
- Order by custom field date with ASC order
- Don’t display html if custom field is empty
- Create a full width responsive header image per page
- Determine when a custom field was last updated?
- Sorting within nested queries / multiple meta keys
- How can I combine meta_query queries?
- custom field value date convert to unix timestamp problems
- How to save taxonomy term meta?
- Can you ungroup Custom Fields?
- Show child pages when on a child page
- Insert attachment ID in custom field from media uploader
- Redirect users based on custom field
- Custom Meta Box not Saving in Posts with Gutenberg Editor
- How can I pass a variable set by ACF to header.php?
- Update Custom post field by Ajax on cached site
- Meta_query is not working on Elementor Custom Query Filter [closed]
- Search pages that are a child of the current page
- How to create html block to display extra information on woocommerce single product page
- Run a check for multiple meta key values
- Getting the ID of any image for use in functions.php
- Unsaved changes in metabox inputs not detected in the block editor
- Advanced search for meta fields
- Declaring in variables [closed]
- Saving Custom Field Data before Publish
- Populate Javascript code with value from WordPress Custom Field?
- Limit of char count in WP custom fields
- how to make nsfw post with thumbanil
- Specific coditional usage [closed]
- Check & remove special characters in a field?
- Google map that plot’s several markers – each one with custom data
- Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle
- query_posts with meta_value
- How to calculate custom field value (average)
- Modify custom field from front end
- How to get all custom fields with some prefix in key?
- Retrieving custom field value with get_post?
- How to Convert Custom Fields from Text to Array?
- Custom Meta Box Upload Image Problem
- Custom Query: query by post custom meta data
- Use update_post_meta to older posts
- Using Custom Fields to Trigger Specific Actions on Saving a Post?
- update_post_meta
- update_post_meta not working well
- Search anything from a Child and Sub-Pages of their Parent page
- WP meta_query args not working in function
- Contact Form 7 List Building
- Link fields in User Admin list
- Advanced Custom Fields deleting some code and adding code for a slider
- Get file size from ACF repeater field
- Childpage title + content on Parent Page
- Query postmeta values, and return multiple post_titles for common meta value
- How to finish this loop?
- RSS Feed in Custom Field
- How do i put a per page theme in a special box/div?
- How can I duplicate “Add Custom Field” with just JavaScript?
- Show or hide custom fields by user’s role [frontend]
- How to automatically create a custom field when a post is published?
- Site uses wpdb to fetch meta_keys but just displays first meta_key from a page (the post uses the same meta_key “filmmaker” more than once)