Apart from the fact, that the conditional is based on a WordPress option, this is pure PHP, but anyhoo:
<?php
$show_views = get_option( 'to_post_views' );
if ( 'Yes' === $show_views ) {
echo '<div class="postviews">' .
getPostViews( get_the_ID() ) .
'</div>';
}
?>
Related Posts:
- Enqueue Javascript Correctly for 3.5
- Best way of adding CSS which can be manipulated by the user via theme option panels?
- Using PHP to toggle stylesheet and header image, set in cookie
- Shortcode content output but not in correct place
- Adding Default Settings to Theme My Login plugin
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to style options page in dashboard?
- Css loads very slow [closed]
- responsive.css in the WordPress should be prioritized
- Redirect to another page using contact form 7? [closed]
- Security for data obtained from the database
- height should be set to auto to avoid pixelation in the post thumbnail function
- How to make container class in PHP
- Creating a mobile site by adding a new class to the body tag from functions.php
- How to Change CSS Colors from Custom Plugin Settings Page
- CSS change in woo commerce Place Order Text [closed]
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Post Views Code Hacks
- how to changes mobile menu toggle breakpoint in WordPress
- PHP function for horizontal Woocommerce thumbnails and badges
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- I got big white screen when i attach main style sheet of Html in functions.php
- Site title not showing. Please help me
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- Add class for the_post_thumbnail_caption()
- Displaying POST content with HTML tags and all
- Highlight Single Page Ancestor
- Styling admin page rows in order of importance (checkboxes)
- How to have Function of a plugin using global vars into a shortcode?
- Cant get theme to change footer color through theme customizer
- How to add margin underneath woocommerce total price amount -> productpages
- How do I get Roboto Google Font to display normal font-style? [closed]
- Load slideshow.css file only if Slideshow is checked / on
- Options.php loop won’t show!
- Echo get_option displays as text
- Sorting Problem
- Dynamic Email Handler with ‘header (“Location: …’
- How to get WordPress Time Zone setting?
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- How to add active class to custom menu using while loop and wp_list_pages
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Add footer.php to WordPress child theme
- WooCommerce – Display variation custom field value [closed]
- Restrict WordPress File Type Uploads by User Type
- Problems with function on function.php
- Want to create Child theme, but already edited Parent theme css files and some php files
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to slow down server response
- Click loads template via ajax
- Missing sidebar parameter “fix” – before_content
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Use menu link or onClick to set a variable
- Automatically remove a canceled order in Woocommerce
- WordPress add post format support not working
- Can I install/embed WordPress on a ‘single page’?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Create highly customized submenu (possibly using wp_list_pages)
- $wpdb->wp_users returning empty value for
- WordPress Custom field Colors
- php syntax : [ && ] between commands [closed]
- Which PHP page is the Default Posts Page
- Need to put a script above tag in header.php – WP 5.7.1
- Sending a custom form data in email through WP Mail Function
- Isotope Drop Down Categories Filter Function
- How to use array in function to get only value I want
- How to remove sidebar primary widget on Mobile on category page [closed]
- How to add PHP code in functions.php wordpress
- add_filter function concatenate string and locate_template function
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- get_page_templates only return templates with “home” in the filename
- Nav-Menu not showing up
- Show different website layout if no sidebar added
- How to pass hook variable to function?
- Let current user know pending posts counts using wp_query
- How to check post meta isset or not empty during publish/save post?
- Get page permalink in contact form
- How to display already created menus via php?
- Grabbing Image name From Product Image Gallery
- Gutenberg block don’t save rich text content
- remove_action from parent theme using child theme functions.php
- Cant get blog name with get_option
- Can’t display anything through homepage text editor
- Extra editor on top of default in Custom Post Type
- Pagination 404 error(I have refreshed the permalinks and tried several previous options)
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- Position a repeated article blocks
- apply_filters() function
- Random text changing to weird icons in both admin & front end
- Using tag to output text in Genesis?
- Save Option on Database
- Add CSS class to PHP Statement
- php “use” not working in template [closed]
- A next page function with shortcode?
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Parse error: syntax error, unexpected ‘}’ in
- Warning: Attempt to read property “term_id” on int – Woocommerce
- WooCommerce Checkout Cart [closed]
- a problem in class in class-wp-hook.php