How to check if atleast one checkbox is checked

Category: Resource

I had an issue where I had a list of checkboxes and I needed that after at least one checkbox is clicked to show a div block.

I came up with this:

$(document).ready(function() {
$('input[name=whatever]').change(function() {
  checked = $("input[name=whatever]:checked").length;
  $('#block').hide();
  $('#block2').show();

  if (checked > 0) {
      $('#block').show();
      $('#block2').hide();
  }
});

Code above checks how much there is checked checkboxes and fires the event if at atleast one is checked.

Here is an example in jsfiddle

Tags: , ,

How to check if page have subpages or childrens

Category: Tutorials, Wordpress

I needed a function for which would check whether page has subpages/childrens or not. So I came up with this:

Just put this code in functions.php:

function post_have_children($id){
	$children = get_pages('child_of='.$id);
	if(count($children) == 0){
		return false;
	}
	else{
		return true;
	}
}

Ussage:

<?php post_have_children('pageID'); ?>

pageID – the id of the page you want checked, can be used $post->ID which would be current page.

Note: check the quotes, because sometimes when doing copy paste they can be copied as symbols.

Furthermore, if you want to check if parent page has subpages/childrens or page has a parent as a conditional tag you can that by using it like this:

<?php if ( $post->post_parent != 0 || post_have_children($post->ID) ) {
	// Show text if page has a parent or Page is a parent and have children/subpages
 } ?>
Tags:

WordPress Catalog Plugin

Category: Announcements

I started building a wordpress catalog plugin, where people can create store data & publish data on pages. I already have a beta version of this plugin which creates new tables in the database and stores information and publishes information, that visitors filled in the form.

Information can be published in any page created via wordpress admin panel. Furthermore information can be stored and modified via admin panel.

Email me if you would like to get the beta version.

Tags:

How to limit WordPress posts title

Category: Tutorials

During my work as a wordpress theme coder I came across that there are request for a function on how to limit the post titles. So here you are the code and hope that it will be useful for you:

Open functions.php in your theme and copy/paste this code:

<?php function limit_title($title, $n){
	if ( strlen ($title) > $n )
		{ 
			echo substr(the_title($before = '', $after = '', FALSE), 0, $n) . '...'; 
		}
	else { the_title(); }
}
?>

Then just put this function where you want in your wordpress theme templates:

<?php limit_title($post->post_title, 30); ?>

Note:

  • Number in the gaps means to how much symbols you want to limit
  • The function should be used in the post loop
Tags:

How To Obtain Proper WordPress Hosting

Category: Tutorials, Wordpress

WordPress hosting has become a top running competitive keyword for many hosting providers, along with shared hosting and dedicated hosting. As more and more hosting companies realize the potential in and client desire for WordPress tailored hosting plans, few still know how to properly accommodate this growing need.

Despite the often slacking serving effort that is the web hosting industry, there are still some providers that offer what we like to classify as proper WordPress hosting. Listed below are five tips that are recommended to consider before settling for wp hosting plan. This is to help you sort the wheat from chaff as you look to host your WordPress site.

1. Do not settle for PHP and MySQL support

The hosting experience for the long-term user is much more than finding the cheapest price and most “unlimited” features. The WordPress CMS runs on PHP script and MySQL databases, but settling for a hosting plan with these two components is not good enough. Besides the fact that most hosts already support PHP and MySQL, a web host need to fulfill a number of other requirements in order to ensure a positive and long lasting user experience.

Look for user reviews, not regarding the host’s server performance or uptime statistics, but what existing hosting customers think about the user interface usability. Is it hard to manage databases, email accounts, domain settings? Is FTP user information available or will you most likely get stuck using the in-house file manager?

Godaddy for example, is both cheap and all-inclusive and thanks to their well known brand and magnitude fools many aspiring internet enthusiasts to set up their hosting with them. However, speaking from experience, GoDaddy’s user interface is a real test on your sanity. It takes weeks to get familiar how everything works. Setting up email accounts is a nightmare. Although GD performs well will little to no server downtime or complications, it is still a hosting provider with highly unsatisfied customers.

2. Do not take our word for it

We could go ahead and recommend a handful of hosting providers that offer WordPress hosting, but it is still safer to take advice from the creators of WordPress. Over at WordPress.org a list has been provided, of hosting companies that according to Matt and the wp-crew can offer the best possible WordPress based hosting on the market.

Another independent hosting guide that ranks hosts for WordPress users is Web Hosting Search. There you will find proper WordPress hosting options.

In conclusion it is safe to say that the web hosting industry as is, rooms many unserious providers. This goes for hosts that offer WordPress hosting as well and seeing as the minimum requirement to host WordPress is PHP and MySQL support, something almost any web host does, it is important to choose your host based on a couple of more factors.

Tags: