Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Custom Field used to allow a Free Story; no longer works

First @TomJNowell is 100 percent right. It was the PHP and my ignorance of it.

Putting in the following code from a year-old backup seems to have fixed the issue in question, if not the underlying improvements that need to be made:

<?php 
    $key = 'Free Story';
    $themeta = get_post_meta($post->ID, $key, TRUE);
    if($themeta != '') {
    $free_story = 1; 
    }
 ?>

<?php if($_SESSION['auth'] == '1' OR $free_story == '1' ) { ?>

NOTE that $post_id from earlier has been replaced with the proper code to call the ID of the current post/page: $post->ID Also note that the TRUE value after $key appears to ask the meta to go through until it finds the $key (Free Story) I want and then operate on that value. I still don’t get what if(@themeta != ”) {$free_story = 1;} is saying. Is it saying that IF themeta is Null or empty, set $free_story to = 1?
Regardless, That’s a learning mission for me. Thank You Tom for your patience!

Related Posts:

  1. How to call plugin path in JS?
  2. Update Multiple Post Meta for the Same Post In One call?
  3. How can I make content disappear when a user logs in?
  4. How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
  5. Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
  6. How to use wp-ajax in wp-cron
  7. White text on white background in TinyMCE when wp_editor is called in WP 3.9
  8. Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?
  9. How can I make the “Preview Post” button save and preview in the same window?
  10. Creating an Exit Confirmation Popup
  11. Difference between register_block_type & wp.blocks.registerBlockType
  12. Add multiple attributes to product from php
  13. Pass a php string to a javascript variable
  14. add mediaelement.js plugins into WordPress video player control bar
  15. Shortcode button dosent work for all posts. Work for first post only
  16. Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
  17. Pulling data from custom plugin settings using PHP shortcode and Javascript
  18. wordpress site | All-in-one-cufon IE Issue
  19. Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
  20. How to get the element ID from new menu list that added with add_filter()?
  21. Override Plugin Script Fucnction in WordPress
  22. add image crop function like in wp customizer
  23. Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
  24. How to edit content before post update
  25. How to insert HTML/JavaScript form into WordPress page? [closed]
  26. How to get my plug-in, wrote in php, to refresh on its own every 5 minutes?
  27. Using TinyMCE in plugin?
  28. Using window.onload with Ubermenu
  29. Redirect to another page using contact form 7? [closed]
  30. JavaScript in a PHP plugin
  31. wordpress add_action() issue in ajax call
  32. Pass user role to javascript code inside body
  33. get specific value of a array | PHP
  34. How to get specific string/value from an array? php [closed]
  35. coding a WordPress AJAX Form using PHP to check if User is Logged Out and Show error
  36. Background Music WP [closed]
  37. How to use custom Javascript code inside a plugin?
  38. Adding a simple Javascript file with a plugin
  39. Social share buttons text shows up on post excerpts
  40. Plugin Admin panel checkbox unchecked after submit
  41. uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
  42. Custom Plugin scripts from admin working in frontend
  43. Code for unique user visit count on every page WordPress
  44. Ajax call not working in wordpress through a plugin
  45. Send Array from JS to php file then insert it in wp database through a plugin
  46. Possible way of having multiple Gutenberg instances for a page?
  47. get_post_meta shortcode returns empty field
  48. Woocommerce add products to cart
  49. Calling PHP function with AJAX
  50. Why does my custom plugin only function correctly once per page?
  51. How to get a specific string from a url
  52. How can I create a secure file download in WordPress?
  53. front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
  54. Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
  55. Problem with wordpress has_action() function
  56. Multiple image selection custom widget
  57. Get and Update Most Meta Value as an array in HTML form
  58. Create a form and have custom menu display based on user answers?
  59. Woocommerce – Change variations output
  60. Speeding up WordPress on a Local Network
  61. Conditional Fields depending on checkboxes
  62. Caching of combined CSS and JS fails because of losing MIME types through combining by PHP
  63. Number format in thousands on highcharts in wpdatatable plugin
  64. Embed Javascript code to registered users only
  65. Same Title on two different post type with single custom taxonomy
  66. How to limit each front-end user to view just his own uploaded files on Amazon S3?
  67. How to create a dashboard for logged-in users with custom functionality? [closed]
  68. Creating a user ‘add custom field’ section
  69. Media Playlist Plugin
  70. How to set up php,javascript and css to allow for our finished product to be displayed within a page?
  71. How do I convince this button to do something when it is clicked?
  72. Can’t insert files in other inputs
  73. WordPress User Frontend Editing Custom Fields
  74. How do I output user_registered time in my correct timezone?
  75. How to tweak a plugin without preventing it from updating
  76. How to create post comparison in wordpress
  77. Adding a script & php to functions.php
  78. how to show selected options drop down menu values in attributes field in after saving post.php
  79. Refresh server side rendered block in Gutenberg without changing attributes or its content
  80. How do I call an action hook into wp_ajax hook callback function
  81. WordPress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted
  82. can not serialize and insert data from custom form
  83. How to resolve Multisite Speed issues
  84. Insert code after tag without using functions.php?
  85. Create plugin that works in background
  86. Checking for user role in a custom plugin
  87. How to get custom field image url of specific size
  88. Google Maps and Yandex Maps doesn’t work correctly
  89. Have Plugin Handle Specific URLs
  90. How do I use WordPress PHP functions in my Javascript code?
  91. Setting up widgets in wordpress with a unique ID for the after_title argument
  92. What’s the best plugin for allowing javascript in a post or page? [closed]
  93. Adding with javascript to admin bar. Works in Chrome/Safari, not Firefox
  94. Deleting images through upload folder, but not deleting from media library
  95. How can i change an image’s author?
  96. Custom Shipping method not showing in checkout
  97. Determining where fopen() is writing files when used from WordPress AJAX call [closed]
  98. Prevent CSS/JS loading when plugin is not used
  99. How to restrict an entire WordPress site to visitors, but the register and login page?
  100. post expire after x days
Categories plugins Tags javascript, php, plugins, post-meta
How to search through “post title” and “tags” using WP_Query?
How to change the canonical link from a category or taxonomy archive?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress