How To Hide Button if No Data Found
-
hero_style is a custom field with web address added by user, when that web address is available it displays the button.
I need it to not show the button if there is no inputed web address?function custom_field() {
global $post;
$url = get_post_meta( $post->ID, ‘hero_style’, true );
echo ‘My Button‘;
}
add_filter( ‘field’, ‘custom_field’ );The blog I need help with is: (visible only to logged in users)
-
Hi, you are in the wrong forum.
This forum is for blogs/sites hosted by WordPress.comWordPress.COM and WordPress.ORG are completely separate and different http://support.wordpress.com/com-vs-org/
And you should ask in the WordPress.org forum.
http://wordpress.org/support/ -
With a WordPress.org site, you’ll have the ability to access theme files so that you can edit the PHP.
Here are the differences between a .org and a .com WordPress site:
-
If you decided to go the .org route, here’s your function modified with a conditional check:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_field() { global $post; $url = get_post_meta( $post->ID, 'hero_style', true ); if ( ! empty( $url ) ) { echo 'My Button'; } } add_filter( 'field', 'custom_field' ); -
We provide support here only for WordPress.COM hosted blogs.
We do not provide support for WordPress.ORG software installs.https://en.forums.wordpress.com/topic/i-cannot-edit-a-page-on-my-website?replies=7#post-2302744
-
- The topic ‘How To Hide Button if No Data Found’ is closed to new replies.