Renaming profile sections

To clarify the “plugin/functions.php” issue, see: Where do I put the code snippets I found here or somewhere else on the web? You can use the following modified version from toscho’s Retranslate Plugin. I changed post_type for pagenow. Configure the translations in the final array. <?php /* Plugin Name: Retranslate Profile Page Description: Adds translations. … Read more

How to get boolean if file A is attached to post B

Get all attachments: $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ) ); Check attachment “parent” for each attachment. foreach($attachments as $attachment){ $parentID = $attachment->post_parent; $postID = $post->ID; if($parentID == $postID){ //your code here echo ‘This attachment belongs to the current post.’; } } But if you already have the attachment, all you … Read more

Hide feature image when is not populated

I guess the <div class=”single-post-thumb” > is the one with the border etc. Change your code to this: if ( has_post_thumbnail( ) ) { echo ‘<div class=”single-post-thumb” >’; tie_thumb( ”, $width, $height ); if ( get_post( get_post_thumbnail_id( ) )->post_excerpt ) { echo ‘<div class=”post_thumbnail-caption”>’ . get_post( get_post_thumbnail_id( ) )->post_excerpt . ‘</div>’; This will cause the … Read more

Dynamically name array in WordPress loop – add/get values

From the PHP manual: Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: ‘[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*’ Hence before diving into your code further: It would need much … Read more

Passing variable from filter

Try to define $count4footer outside the function wpa_filter_nav_menu_objects. $count4footer = array( ); function wpa_filter_nav_menu_objects( $items){ global $count4footer; foreach( $items as $item ){ $count = countPosts($item->ID); if($count!==false){ $item->title = $item->title.” ($count)”; $count4footer[$item->ID]=$count; } } return $items; } add_filter( ‘wp_nav_menu_objects’, ‘wpa_filter_nav_menu_objects’ );

WordPress editor, change code wrap (bbpress?)

put this code in functions.php add_action(‘wp_footer’,’ravs_codeTag_fix’); function ravs_codeTag_fix(){ if ( bbp_use_wp_editor() ) : ?> <script> jQuery(document).ready( function() { /* Use <code> instead of backticks for the Code button in the editor */ if ( typeof( edButtons ) !== ‘undefined’ ) { edButtons[110] = new QTags.TagButton( ‘code’, ‘code’, ‘<code>’, ‘</code>’, ‘c’ ); QTags._buttonsInit(); } }); </script> … Read more