$combined_views = (int)$get_visit_query + (int)$offset;
This doesn’t make much sense. $get_visit_query
is a string (your query). Converting it to int
returns in 0
, see this snippet. Instead it should be
$combined_views = (int)$visits_total + (int)$offset;
Sidenote: Are you actually hooking the function via add_filter()
? If not, apply_filters('get_post_views', ..)
will not have the desired effect. Using the function name doesn’t magically add it to the filters, you need to explicitly define it e.g. via add_filter('get_post_views', 'get_post_views', 10, 2);
.
Related Posts:
- Modify post image in full size
- Build a content and excerpt grid loop with paging and options for # of posts
- Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
- How to add 2 posts under another post? Formatting should be intact
- Modern Tribe Calendar wp-query with meta query not working at all
- How to display custom field on homepage
- Can an array be used as a meta_query value?
- Use wp_get_recent_posts with search term
- Remove query string specific key value
- Why is variable not working on custom sql query using wpdb?
- Display fields as values in array from external SQL DB
- Trying to establish connection to External Database
- WP Query with custom Shortcode
- How to insert a single row to WP database table?
- WSoD being caused by this piece of code
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Wp_query function to search from product_title ‘OR’ product tags name
- How to prevent WP_Query function from returning all posts when empty?
- Display a specific category of products in shop page and disable code for specific actions
- Get users that likes the post
- Custom query, checking values of multiple meta keys
- Remove echo from shortcode
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Security for data obtained from the database
- Fatal error: Call to a member function query() on a non-object
- Is it possible to retrieve all posts with a certain value for metadata?
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- How to retrieve the data from the sever and displaying it in a page?
- WP_Query: getting posts where custom field exists
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- change the default order of posts only for specific categories
- How to use mysql LIKE with wpdb?
- How to hide posts of a specific custom category in WordPress?
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Post not populating for custom post type based on category selection
- Passing an array into WP_Query as a variable
- Custom query vars filters problem with pagination
- WordPress meta_query >= &
- Change MySQL PDO connection to a WPDB connection
- How to get post category list as select in front-end?
- Displaying Event within two given time frames
- WordPress SQL JOIN query
- Let current user know pending posts counts using wp_query
- Output product category link from WP_Query
- “pre_get_posts” orderby custom date field in different format?
- Passing in MySQL prepare statement parameter separately throwing error
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- How to exclude meta no index pages from wp_list_pages
- wp_Query with mutuplea values returns all posts
- meta_query search names when they have middle initials
- WP query posts BUT show the most recent and one per author
- Ajax filter with loadmore button
- posts_per_page displays only 2 posts instead of 4 posts
- Usermeta data unserialize, extract and display in table in WordPress
- Delete post meta by serialized meta value
- WP_Query To Display Product Of Brand On Taxonomy Page
- Meta query not showing result properly
- Custom Post type Ajax search results
- How to return count of items found in SQL query
- My query keeps looping infinitely ! how to stop it?
- Efficient way of querying for a “fallback” post?
- How can I display a query in a page?
- Display Year and Month from custom field + Age Calculator
- insert thumbnail image from php script
- Weird Behaviour: Not all WordPress Posts appearing
- List sibling pages widget, exclude current page
- How to get category pages to look like a certain archive page?
- How to modify this function to exclude also the post belonging to a specific category?
- posts_clauses drop ACF get_field function
- Changing regular db connection to $wpdb
- get second ID from array
- a problem in class in class-wp-hook.php
- /page/2/ redirect to 404
- Add adjacent post function inside custom recent post function
- wp_logout action hook is not firing
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Developing a “fallback” for empty wp_query results based on post dates
- Trouble getting wpdb to work – first time
- Display posts in correct month order using single date custom field
- Slide in Panel WordPress Post
- Changing Woocommerce flat rate every nth number of items
- Shortcode content output but not in correct place
- Ajax $wpdb not returning table data
- Converting MYSQL to WordPress $WPDB
- Convert all images to PNG on file upload
- WP_Query loop, does not display special characters in title correctly
- How to restrict page access to logged-in users?
- is_page “range” for if statement?
- Calculations in functions.php [closed]
- How to Fetch values from WP database based on selected option value by onchange using PHP?
- If search results empty then execute certain code
- Shortcode return function with link href inside PHP
- Can’t load WP function into external function
- Hide post if matches current month and year
- Count the number of times the search form template gets included on a page
- PHP code inside shortcodes
- Get the last month with posts using a recursive function…
- Limiting woocommerce line_total decimal length
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Use WP_Query in shortcode