Tag Info

Hot answers tagged

3

As per you described, What I have got is you want to add class active to last published post by the user. By seeing your output and HTML, It seems that active class is missing. So to achieve that, we will add one dummy condition that will print class="active". I would also suggest that modify your $arg and make in DESC order to get last published post ...


2

Your argument for is_singular() is wrong It should be an array is_singular(array('post','movie')) You can read more about the argument passed from this link here


1

You have one or two problems here is_category() should be object of $query in your example code get_query_var('post_type') will always return false on a category page AFAIK, so that code is totally unnecessary Just a tip, when using pre_get_posts with any type of archive, also check for non admin pages as your back end will also be affected by this change ...


1

You should be using a tax_query for this operation. The category parameters won't work with custom taxonomies Instead of 'category' => $catID, use 'tax_query' => array( array( 'taxonomy' => 'series', 'field' => 'term_id', 'terms' => $catID, ...


1

As I said, this whole setup you are after is not possible natively with pretty permalinks. Your setup probably works with default permalink structure as both queries (the main query and your custom query) read these permalinks in the same way. When you switch to pretty permalinks, the two queries on the single page interpret the URL differently causing one ...


1

You can get the list of other posts with same post parent by running a custom query. You should supply parent post id in post_parent parameter to WP_Query and exclude current post from custom query. So this will be the custom query. $parentpost = wp_get_post_parent_id( $post->ID ); if ( $parentpost && $parentpost != '0' ) { $currentpost = ...


1

The first section of this question have been answered before. Basically, there are no index pages for archives, and there never will be. For a complete explanation, feel free to check this post I have recently done on this subject. Why did wordpress think that is post_name and post type is post? You might or might not know this, but Wordpress uses ...


1

You have missed meta_value parameter. You can use like this : $today=date('Y-m-d'); $args = array( 'numberposts' => 10, 'post_type' => 'events', 'meta_key' => 'event_date', 'meta_value >=' => $today ); // get results $the_query = new WP_Query( $args );


1

WordPress allows to do this rather neatly for pages, supporting page-$slug.php and page-$id.php templates in hierarchy. Unfortunately it doesn't apply to posts and Custom Post Types. So your options are either handling this inside single-services.php (in one file, or by further including other template files) or adjusting hierarchy to use custom templates ...



Only top voted, non community-wiki answers of a minimum length are eligible