Post belonging to many categories

If the template is using the permalink when generating the posts, it retrieves all the categories for a given post and then grabs the first category it gets after sorting them by Id. I see two ways around this: If you want to recreate your categories with the preferred order, then you should be set. … Read more

Get_the_terms restrict output

you can change you code a bit : $taxonomy = ‘country’; $terms=get_the_terms($post->ID,$taxonomy); if($terms) { echo ‘<h1>Holiday ‘; $total_count = count($terms); $country_count = 1; foreach( $terms as $termcountry ) { if ($country_count = 1){ echo ‘in ‘.$termcountry->name; }else{ if ($total_count = 2){ echo ‘ And ‘.$termcountry->name; }else{ echo ‘, ‘.$termcountry->name; } } $country_count = $country_count + … Read more

Stop wordpress from creating empty/null entries

When i needed a solution to the save “problem” i create an Ajax function to validate the fields and did some minor JQuery hacks: first we add our JavaScript to capture the submit/publish event and use it to submit our own ajax function before the actual submit add_action(‘wp_print_scripts’,’my_publish_admin_hook’); function my_publish_admin_hook(){ if (is_admin()){ ?> <script language=”javascript” … Read more

displaying flv-video attachment in post

The .flv is not a video player in itself, rather just a video file to be played in one. To display it, you’ll need to play it from an actual video player. Unlike .wmv and .mp4, .flv files won’t play natively in your browser without one. There’s a couple great open source options out there. … Read more

Is it possible to give the user the chance to select between two single template files to use in a post?

If the differences in the pages are just query arguments the you can add query vars and use them in the same template: //add your arguments to query vars add_filter(‘query_vars’, ‘my_query_vars’); function my_query_vars($vars) { // add my_sortand ptype to the valid list of variables you can add as many as you want $new_vars = array(‘my_sort’,’ptype’); … Read more

Manage Private Posts

You could perhaps: 1) Create the category for your Private posts, e.g. “Private” 2) Exclude the “Private” category from your main Loop 3) Output the “Private” category using a custom template file, e.g. category-private.php 4) Wrap the Loop in category-private.php in an if ( is_user_logged_in() ) conditional (This assumes, of course, that you are the … Read more