Okay, so here is the complete query for displaying popular posts of current week. I am using meta_query
to limit query results within current week only.
It will get all posts from current week and then sort them by post views count added by custom field wpb_post_views_count
that you used in your question.
// Current week's popular posts
$query_args = array(
'post_type' => 'post',
'date_query' => array(
array(
'year' => date( 'Y' ),
'week' => date( 'W' ),
),
),
'meta_key' => 'wpb_post_views_count',
'orderby' => 'meta_value_num',
'ignore_sticky_posts' => 1,
'posts_per_page' => '-1',
);
$my_query = new WP_Query( $query_args );
if ( $my_query->have_posts() ) :
while ( $my_query->have_posts() ) : $my_query->the_post();
// add your loop content here.
endwhile;
endif;
wp_reset_postdata();
Related Posts:
- Featured image in menu wordpres
- Trying to update Woocommerce meta values
- How do I know if the user is a customer?
- How to block specific user id in custom login form?
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- update_user_meta as multiple value but with same meta key
- I want to fusion the product columns in email table order
- retrieve “Link Color” value
- Inserting a class on before_widget if checkbox is checked
- If Statement is Ignored?
- Add a new view on the Woocommerce account page
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- Delete post meta by serialized meta value
- How do I add a predefined class to a custom html element?
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- How to identify which php file a plugin is using on page load?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Dynamic “home” image and URL based on current folder
- Change WooCommerce currency programmatically on AJAX request
- Dynamic Banner Text based on Subdomain
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- Need help transforming echo to return for use with shortcode
- How to separate the taxonomies list from the form so that editing taxonmies is the same as pages and posts?
- Noob question: want to remove the “site identity” logo for specific part of website only
- How to display dual language menus and headers?
- Create Schema in WordPress with PHP
- Redirect after login depending on the URL
- Create form which redirects to site in network?
- Redirect user role to a specific page on login in a multisite network?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Redirecting the lost password page request when using a custon login page
- Add custom attribute to product’s HTML to woocommerce cart page
- Create custom admin page with custom text fields
- Autoloading Classes in Plugins
- Remove specific javascript when viewing page in Customizer?
- Search only for posts with specific metadata?
- How to Get Linked Elements for a specific ml_source_elementid
- Query to show average # of months all accounts with specific role have been active
- Conditionally change WordPress core language
- Running local copy of an old WordPress site on MAMP
- Remove node from multisites?
- Automatically refresh page if widget is added to page?
- custom field – changing an element or background of id div – different versions not working
- Real time notification on user profile after new comment
- Customizing WooCommerce with PHP
- How to add text before posts
- Multisite – Display different header content based on which site is accessed
- How to get php file based on URL in WordPress
- Multilanguage website on two different domains
- Add two or multiple functions in WordPress Post or Page
- What image is this pulling?
- How can I customize a WordPress theme before it’s downloaded?
- Show content by using tags
- How to associate dynamic PHP page for chosen WordPress tag?
- Only display notification on single post
- Is there a way to have chunks of a page’s content expire?
- Replace Underscore (_) on Space ( )
- Where can I find the declaration of `$_wp_theme_features`?
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- Why isn’t my custom Javascript showing up in my custom template?
- Showing the project type in HREF
- WordPress error on my website
- Display tab title as ‘blog tagline | blog title’
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- PHP call div with function
- Use custom get results query to show posts WordPress
- Showing custom field contents without listing description
- How can I show only if custom field has content [closed]
- media-uploader insert into post is not inserting
- How to use PHP code with wordpress page
- Best way to define a database with product codes and back-end support?
- How to show all of aspecific post type that has taxonomy and a specific term
- wp_customize_image_control default value
- Check if values exists DB
- How to hide something from custom home page with php code?
- if is_bbPress register jquery
- Auto create description in post
- Pagination on Custom Loop
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Widget header unique classes
- why is this content-template not showing any of my blog-entries?
- How to get the count for each taxonomy term
- error with WP custom form
- Where can I find the code for the menu page meta boxes?
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- How to add button to top of theme customizer?
- How can I clear the theme mod settings?
- MySQL Engine vs. Charset
- Woocomerce custom add to cart button edit functionality [closed]
- Capture the Selected Radio Button Value between two files in wordpress theme
- fetch from an external api call and display results in page
- make my custom theme support polylang plugin
- Partial refresh in WordPress live preview
- How to change product title color in shop page if product has specific product tag (Woocommerce)?
- Insert attributes names according to language with polylang programmatically
- How to capture number input from wordpress form into acf field in woocommerce
- Restricting page by user role
- Add More Featured Data Not Sending to Database