Hide sidebar if post_type is in array

This is more php, but you can use in_array(). Just check if the current post type is in array in $hide_sidebar. You can do the following $hide_sidebar = array(‘example1’, ‘example2’, ‘example3’); //hide sidebar on these post types if ( in_array( get_post_type(), $hide_sidebar ) ) { // Do something if the post type is in array … Read more

Get archives as array

If you look at wp_get_archives() you will notice that the link is generated by get_archives_link(). That function supplies a filter that will allow you to replace the parens. This is fairly crude but does work. function archive_link_wpse_183665($link) { $pat=”|\(([^)])\)</li>|”; // preg_match($pat,$link,$matches); // var_dump($matches); $link = preg_replace($pat,'[$1]’,$link); return $link; } add_filter( ‘get_archives_link’, ‘archive_link_wpse_183665’ );

Get html data with javascript to php array and store to wordpress database

Here is my own solution. In my html I’ve assign id to all the item and inside the form I’ve added an input option where I pass the value through the script and it was saved later. Simple… script jQuery(document).ready(function($){ $(“.sortable”).sortable({ connectWith: ‘.sortable’, receive: function (event, ui) { document.getElementById(‘hello1’).value = myFunction(); }, out: function (event, … Read more

Query Custom Post Types with checkboxes

You aren’t constructing the meta_query correctly. It is close but not quite right. $searchArray = array(); $searchArray = array(‘relation’ => ‘OR’,); // here is the change // loop over checked checkboxes if(!empty($_POST[‘course_location’])) { foreach($_POST[‘course_location’] as $check) { // echo ‘<h1>’.$check.'</h1>’; $searchArray[] = array(‘key’ => ‘course_location’,’value’ => $check,’compare’ => ‘LIKE’,); } } As you have it … Read more

Filtering a function’ output for a new continued function

How about using a standard for loop instead: $sunnytags = get_tags ($tagargs); $count = count ($sunnytags); for ($i = 0; $i < ($count < 15 ? $count : 15); $i++) { $string .= ‘<a class=”tag2″ href=”‘. get_tag_link ($sunnytags[$i]->term_id) .'”>’. $sunnytags[$i]->name . ‘</a>’; } And then later, whether you re-run the query or (better still) save … Read more