Is there anyway I can call the year once?
Is there anyway I can call the year once?
Is there anyway I can call the year once?
LOL– I had to just add posts_per_page in my $terms_year query. Leaving this up in case people need it… $terms_year = array( ‘post_type’ => array(‘publications’), ‘posts_per_page’=>-1, );
Assuming you are using the standard WordPress search, you can get the searched number with get_search_query So this code will create a new draft post if no results were found for the search: $match = get_page_by_title( sanitize_title( get_search_query() ), OBJECT, [‘post_type’ => ‘post’] ); if ( empty( $match ) ) { wp_insert_post( [‘post_title’ => sanitize_title( … Read more
There are ways to loop through all the sites in a multisite, then do a “WP Loop” on each sub-site. It can get a bit complex, but it can be done. I did some research on this, and found some code fragments that would do it, but no full-on solution. So I wrote my own … Read more
The query_posts() function is almost wholly unnecessary and is discouraged in favor of WP_Query(). That being said we can look at the WP_Query() docs as they’re almost the same. The cat parameter accepts either a comma separated string or integer. In this case we can use: query_posts( array( ‘cat’ => 1, ‘posts_per_page’ => ‘8’, ‘post__not_in’ … Read more
ElasticPress is (aparently) messing with my search filters
Duplice post with standard WP loop – fixed by using query_posts() instead
How to create loop of posts except post ID defined via ACF field
How to get max value of filtered query post
Here I put orderby attributes as option values – date and title. <form method=”GET”> <select name=”orderby” id=”orderby”> <option value=”date”>Newest to Oldest</option> <option value=”title”>Alphabetical</option> <button type=”submit”>Apply</button> <form> On the same page you can recieve select value and set as orderby attribute $wpb_all_query = new WP_Query(array( ‘post_type’=>’post’, ‘posts_per_page’=>-1, ‘order’=>’ASC’, ‘orderby’=> esc_attr($_GET[‘orderby’]) ); Use your loop to show … Read more