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 do I make a shortcode to display Dokan seller badge list?
- How can we upload custom page files?
- Calling a PHP function from a menu item
- Hide or Show Read More Button by Content Area
- username_exists() function can’t be access without logging in
- How to target with css, admin elements according to user role level?
- Remove/unset options field from backend Settings->General?
- Site Title and Tagline in Theme Options Page
- Check if page parent has certain template
- Delete post revisions on post publish
- How do I list the_tags() into HTML data-attribute
- WordPress if (is_page) translation on certain page
- Highlight Current Tag in wp_tag_cloud
- Getting rid of role=”navigation” in the Home Page Pagination
- How to use return in my custom function instead of echo
- How can I hide Home in my menu in a specific page?
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- get post based on category chosen in drop down – The ajax method
- how to make separate field in wordpress user_data_
- Set the background to a default image if there isn’t a specified “featured image”
- WordPress Access allowed to fewer pages till user logs in
- different id for same element visual composer [closed]
- Tax query in pre_get_posts not working
- Filtering a function’ output for a new continued function
- Shortcode to find and replace URL
- Deleting Certain terms from appearing on the front end as links
- Styling the second sidebar
- first instantiated SimplePie object cosumes 5mb?
- Theme not calling Jquery properly
- How to add drag and drop functionalities to a div inside option panel
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- WordPress redirect redirecting too many times or not at all
- Add value to new attribute inside WordPress menu items
- Please show me how to use an if/else statement in combination with wp_enqueue
- If Array Values Match Another Array’s Values, Then
- entire JS folder not loading in a WP theme
- Open and closed function [closed]
- Else/If Statement to Display Photo Descriptions
- Count foreach and display in menu php
- Display additional page templates and a sidebar on plugin activation
- Remove role of user after X days
- Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page
- Background image no longer fits to screen now that project is in php files
- if get_post_meta is empty echo a placeholder or shortcode
- PHP multiple forms, same page, isset($_POST[]) not working?
- Outputting post content to jQuery .html() string
- I cannot find the wordpress.scss file that my live site is pulling from
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- How to update option field in database on clicking the publish button in customizer
- Add ID to output only for first option
- Display text of price (minus 20%) on every product page in a sentence.
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- How to make 2 similar functions more efficient
- Echo multiple tasks if a common function exists
- Add end mark at the end of every article
- Functions are causing errors
- Global variables and re-use
- Link to external page has wordpress blog-url inside
- AJAX: WordPress filters inside $html do not work as intended
- Why a class property becomes empty?
- How do I stylize selected comments?
- How can I process a form submission from an HTTP POST request?