Skip to content

Instantly share code, notes, and snippets.

@ivandoric
ivandoric / gist:11215603
Created April 23, 2014 13:41
drupal: Print out user fields
<?php
/*use print_r($user_profile['field_name']); to check out the array */
/*Some examples of this method */
<li><?php print $user_profile['field_drzava']['#title'] ?>: <?php print $user_profile['field_drzava'][0]['#markup'] ?></li>
<li><?php print $user_profile['field_tel_']['#title'] ?> <?php print $user_profile['field_tel_'][0]['#markup'] ?></li>
<li><?php print $user_profile['field_fax_']['#title'] ?> <?php print $user_profile['field_fax_'][0]['#markup'] ?></li>
<li><?php print $user_profile['field_sjediste_firme_']['#title'] ?> <?php print $user_profile['field_sjediste_firme_']['#items'][0]['value'] ?></li
@ivandoric
ivandoric / gist:11215625
Created April 23, 2014 13:41
drupal: Get author user name from $uid
<?php
$username = $node->name;
print $username;
?>
@ivandoric
ivandoric / gist:11215642
Created April 23, 2014 13:42
drupal: If content type do something
<?php if($node->type=='node-type-name'){ ?>
@ivandoric
ivandoric / gist:11215689
Created April 23, 2014 13:43
wordpress: Title for custom Wordpress pages, that have special loops on them
<?php
$post_id = $wp_query->post->ID; // get post ID
?>
<h2><?php echo get_the_title($post_id); ?></h2>
/* If using WPML for translation then */
<h2><?php echo get_the_title(icl_object_id($post_id, 'page', false)); ?></h2>
@ivandoric
ivandoric / gist:11215702
Created April 23, 2014 13:44
sublime: Always use same indentation
Add this to Preferences - Settings user
"tab_size": 8,
"translate_tabs_to_spaces": true,
"auto_indent": true,
"detect_indentation": false
@ivandoric
ivandoric / gist:11215753
Created April 23, 2014 13:46
wordpress: Filter posts by comparing meta value
<?php
$trenutnovrijeme = strtotime('now');
query_posts( array(
'post_type' => 'javna-nadmetanja',
'orderby' => 'wpcf-datum-objave',
'meta_key' =>'wpcf-datum-zatvaranja',
'meta_compare'=>'>' ,
'meta_value' => $trenutnovrijeme,
'order' => DESC,
'showposts' => 10,
@ivandoric
ivandoric / gist:11215772
Created April 23, 2014 13:46
wordpress: More that works on pages and posts
<?php
global $more;
$more = 0;
the_content('');
?>
@ivandoric
ivandoric / gist:11219021
Created April 23, 2014 15:06
wordpress: Automatically add category to post when certain other category is selected
<?php
function add_category_automatically1($post_ID) {
global $wpdb;
if(in_category(7)){
$cat = array(10);
wp_set_object_terms($post_ID, $cat, 'category', true);
}
}
add_action('publish_post', 'add_category_automatically1');
@ivandoric
ivandoric / gist:11219045
Created April 23, 2014 15:06
css: Target only Firefox with CSS
@-moz-document url-prefix() {
ul.nav li a {
padding:0 15px 2px 15px;
}
}
@ivandoric
ivandoric / gist:11219071
Created April 23, 2014 15:07
sublime: No "map to remote" command solution
To fix this, please perform the following:
Open Preferences > Browse Packages…
Navigate into the SFTP/ folder and open SFTP.py in Sublime.
Without making any modifications, save the file. Sublime SFTP should now be fully functional again.