Ajax loop in sidebar to load post titles/categories

What is the script for you posted here? I hope it is not the script that will be called by the ajax request, isn’t it?? Normally a php script for an ajax request looks like this: <?php $output = array(); $posts = new WP_Query( array( ‘showposts’ => 20 ) ); foreach ( $posts as $post … Read more

Getting Permalink within the loop

As suggested, went to the function reference and from there to the Source File (located in wp_includes/link-template.php) in which there are four functions that each return similar results. <?php echo get_post_permalink() ?> http://newdep.localhost/instruments/jester/ <?php echo post_permalink() ?> http://newdep.localhost/instruments/jester/ <?php the_permalink() ?> /instruments/jester/ <?php echo get_the_permalink() ?> http://newdep.localhost/instruments/jester/ In this case, since this is a custom … Read more

Getting page ID inside loop

You can use all template tags inside this file, so to get the ID, just use get_the_ID() (or the_ID() to output it). get_the_ID() will retrieve the numeric ID of the current post. It has no parameters and returns the ID of the current post. the_ID() will display the numeric ID of the current post. It … Read more

WooCommerce – Show orders for a specific product ? [closed]

Eric based on your code I wrote to meet my needs, for those who want to follow: Eric com base em seu código eu escrevi o para atender as minhas necessidades, para quem quiser segue abaixo: <?php global $wpdb; $produto_id = 22777; // ID do produto $consulta = “SELECT order_id FROM {$wpdb->prefix}woocommerce_order_itemmeta woim LEFT JOIN … Read more

User Defined order on get_categories?

I think the most sane way and easiest way of doing this is to unset the first value in the returned array, and then adding it back at the end of the returned array before your foreach loop For this to work, you will need to sort your categories by ID as you need to … Read more

Sort Popular Posts by Views for the Last Week

Use strtotime to compare dates. $start = strtotime(‘yesterday’); $end = strtotime( ‘+1 week’,$start); $args = array( ‘posts_per_page’ => 5, ‘ignore_sticky_posts’ => 1, ‘meta_key’ => ‘sw_post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘date_query’ => array( ‘after’ => $end, ‘before’ => $start, ), ); $popularpost = new WP_Query( $args ); if ( $popularpost->have_posts() ) { while ( … Read more