How to use global post counter in the loop?

As I already stated in a comment, You need to use get_option( ‘posts_per_page’ ) and get_query_var( ‘paged’ ) to calculate your post numbers You can do something like the following: (I have commented the code to make it easy to follow. This goes into functions.php) function get_post_number() { global $wp_query; /* * Get current page … Read more

Using AJAX to return search form results

There are two issues in your code You need to add script in wp_enqueue_scripts hooks like this – add_action(‘wp_enqueue_scripts’, ‘my_custom_js_script’); function my_custom_js_script() { wp_register_script( ‘ajax-productSearch’, get_template_directory_uri() .’/js/ajax-product-search.js’, array( ‘jquery’) ); wp_enqueue_script( ‘ajax-productSearch’ ); wp_localize_script( ‘ajax-productSearch’,’the_ajax_productSearch’, array(‘ajaxurl_productSearch’ => admin_url(‘admin-ajax.php’))); } The second issue is that, you need to add action argument in your jQuery.ajax data. If … Read more

List taxonomy terms plus their latest post ordered by post date

Right now you are performing the query by term, and displaying results instantly. What you need is to gather the results of each query, sort them and then display separately. Make sure to read code comments. /* $custom_terms = get_terms(‘columna’); – this approach is depreciated */ $custom_terms = get_terms( array( ‘taxonomy’ => ‘columna’ ) ); … Read more

Get only 1 Most Recently Modified Child Post from Parent

I think maybe you don’t need Wp_Query. I believe you can just do $episodes_for_front_page = array(); //get the two dramas $dramas = get_posts(array(‘post_type’ => ‘drama’)); foreach ($dramas as $drama){ //get all the episodes belonging to that drama, sorted by most recent update $episodes = get_posts( array( ‘post_type’ => ‘episode’, ‘post_parent’ => $drama->ID, ‘orderby’ => ‘post_modified’, … Read more

How can I style future post?

Just use the function get_post_status(). Inside the loop you have access to the Post Id, but if you leave this blank it will use the ID of the current post instead. So you code will become something like this (not tested yet): <h3 class=”entry-title td-module-title”> <?php if( get_post_status() != ‘future’ ) { ?> <a href=”<?php … Read more

How to display child posts in the parent category

You need to use a tax_query with WP_Query. With a tax_query, by default, child terms are included to the term being set. Here is the example- $args = array( ‘post_type’ => ‘post’, // Your post type ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘rankk’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 100, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)