How to limit the number of results for all query_posts on mysite

It is not that hard to enforce a hard limit on results: add_action( ‘post_limits’, function($limit) { $limits = explode(‘,’,$limit); if (isset($limits[1]) && 2000 < $limits[‘1’]) { $limits[1] = 2000; } $limit = implode(‘,’,$limits); return $limit; } ); I would not be surprised if that does not solve your problem though. Just searching over that many … Read more

Display metabox with date

In database, it stores the date details with prefix as _start and _end so you need to change the meta keys accordingly. Please have a look at the below code. <p>Start time details</p> <p>Date: <?php echo get_post_meta($post->ID, ‘_start_day’, true);?>.<?php echo get_post_meta($post->ID, ‘_start_month’, true);?>.<?php echo get_post_meta($post->ID, ‘_start_year’, true);?></p> <p>Hour: <?php echo get_post_meta($post->ID, ‘_start_hour’, true);?>:<?php echo get_post_meta($post->ID, … Read more

How to set a link to custom archieve page

I am working on my blog where I wish to have a archieve for only specific category post. If I understand you, you are doing this wrong. What you want to do is use pre_get_posts to restrict your archives to the one category. Something like this: function restrict_archives_to_cat($qry) { if ($qry->is_main_query() && $qry->is_date()) { $qry->set(‘cat’,5); … Read more

Load Pages Menu in single.php

Yes you can. <?php $args = array( ‘theme_location’ => ‘primary’, //change this value with coresponding menu area ‘menu_id’ => ‘main-menu’, //change this value with wanted menu ); wp_nav_menu($args); ?> menu_id is the name of menu created in WP admin>Menus. I create menu with name “Main menu” so I put main-menu there. That menu is connected … Read more

How can I get a comment ID on Submit?

You can hook comment_post and add your logic with the comment id // Save the data along with comment id add_action( ‘comment_post’, ‘wti_save_comment_data’ ); function wti_save_comment_data( $comment_id ) { // Use the comment id and add your logic }

find posts with exactly 3/4 categories

Make sure you are providing correct category names into the function get_cat_ID(). <?php $catIDs = array(); $catIDs[] = get_cat_ID( ‘CategoryName1’ ); $catIDs[] = get_cat_ID( ‘CategoryName2’ ); $catIDs[] = get_cat_ID( ‘CategoryName3’ ); $my_query = new WP_Query( array( ‘category__and’ => $catIDs ) ); if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post(); ?> <li> <a href=”https://wordpress.stackexchange.com/questions/125935/<?php the_permalink(); … Read more

Displaying Results From Custom Taxonomy Query

$regions = get_terms(‘region’, array(‘hide_empty’ => false) ); foreach( $regions as $region ){ ?> <li class=”location large-3 columns”> <img src=”https://wordpress.stackexchange.com/questions/126131/<?php echo get_template_directory_uri(); ?>/images/<?php echo $region->slug; ?>.jpg” alt=”” /> <span class=”location-title”><?php echo $region->name; ?></span> </li><?php }