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?
- Displaying child pages and file URL in an ACF relationship field shortcode
- Display custom fields only if it has a value
- Custom fields and auto save
- Define an extra field for all pages (with no plugin?)
- Save values generated via API as custom meta fields
- How to show the view more on my display of pages shortcode
- Extra text’n’image field in a page
- Ordering posts by custom fields
- Get first URL from custom field, download and set as featured image on post publish
- Childpage title + content on Parent Page
- Query postmeta values, and return multiple post_titles for common meta value
- Query Custom Fields in Searchform
- Make custom user_meta as permalink for post
- Creating Structured Documents (books) in WordPress?
- Term specific featured post on taxonomy archive pages
- How to copy specific page content and create child page?
- Filter query based on date in custom field
- List of child pages fetch next results at link click
- Populate a select box with data stored in the database?
- How to display data with pagaination on backend?
- Custom Post Field -> Returning only the word “array”
- Register author, facebook connect, publish posts from front end
- How do I use foreach to get content from a custom-field in multiple posts?
- Custom field and category query
- Empty the_content for all posts
- When post is updated, custom metadata in text area field is overwritten
- Updating custom fields with external data
- How to disable ‘enclosure’ custom field link from appearing in the post
- Thirtieth century date for a post
- Pages redirecting to homepage
- How do you turn a custom field’s value into a permalink for that post?
- WordPress taxonomy child image
- Call the latest posts from a custom field group to be displayed on front-page
- Create custom fields/meta data gender+country – radiobuttons and dropdown on register screen for these fields
- Using wp_list_pages to create 2 lists of pages and include and exclude some of them depending on their category
- Permalink structure depending on custom field
- Add nofollow to custom field link and make domain exceptions?
- change attachment custom field onChange event
- Wrap this custom field with hyperlink link
- Add custom field to post with some part of url as value
- Paying to Access Custom Fields Per Post
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- How to diplay a div only if at least one author custom profile field is filled?
- Set custom field value when reaching expiration date
- Get custom fields when hover link of post
- Filter and display a specific custom field value [closed]
- Firing page_publish where page is child page
- WP_query returns error when used for custom widget
- Adding custom fields to images
- How to save dynamically generated value in post type?
- How to finish this loop?
- Is it possible in WordPress
- Change path to child of page when uploading image via custom field
- How can I hide my section title if there is no data in custom fields?
- How To List Sibling Pages And Include The Featured Image?
- Is it possible to make one of two custom fields in Custom Post Type UI Required but not the other?
- Set Value To Custom Field While Submit
- Saving metadata of related post on save_post
- Extend WP_Customize_Control with Multiple Field Control
- Related post thumbnail not showing up
- Convert all dates in field to Unix time, except those already in Unix time