Status
Not open for further replies.

kuskka

Active Member
456
2011
110
50
In this thread I will post some Wordpress shortcodes that will help you in websites development.

This thread will be always updated, so keep it bookmarked!

How to change post thumbnail crop position in wordpress:
- Open media.php file under wp-includes folder.
- Find the function named “image_resize_dimensions” (Around line 309). Unfortunately this function is not pluggable and doesn’t use any hooks so we will edit it directly. Find the lines:

Code:
$s_x = floor( ($orig_w - $crop_w) / 2 );
$s_y = floor( ($orig_h - $crop_h) / 2 );
Change the second line to

Code:
$s_y = 0; //floor( ($orig_h - $crop_h) / 2 );
Save the file and upload it to wp-includes folder.

Source: http://shailan.com/781/how-to-change-post-thumbnail-crop-position-in-wordpress/

--------------------------------------------------------------------------------------------------

How to disable text editor in Wordpress:

Place this code in your functions.php file.

Code:
add_action('init', 'my_remove_editor_from_post_type');
    function my_remove_editor_from_post_type() {
        remove_post_type_support( 'post', 'editor' );
    }
--------------------------------------------------------------------------------------------------

How to get Featured Image URL:

In some cases in just want the URL of a featured image, for this, you can use this code:

Code:
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
    <?php echo $image[0]; ?>
<?php endif; ?>
Remember to change the "single-post-thumbnail" to the size you want. You can use: full, medium or thumbnail.

--------------------------------------------------------------------------------------------------

Removing trash from <head>:

By default, Wordpress add a lot of code inside your <head> that probably you will never use. To remove it, place this code inside your functions.php:

Code:
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
--------------------------------------------------------------------------------------------------

Shortcode for YouTube videos:

Place this code on your functions.php.

Code:
add_shortcode( 'youtube', 'youtube' );
function youtube( $atts, $content = null ) {
    return '<p itemprop="video"><iframe width="640" height="350" src="http://www.youtube.com/embed/'.$content.'?theme=light&autohide=1&showinfo=0;wmode=opaque;border=none;iv_load_policy=1" frameborder="0" allowfullscreen></iframe></p>';
}
Usage:
Code:
[ youtube]VIDEOID[/youtube]
 
Last edited:
11 comments
looking for more :)
Can you sort out the problem with Facebook javascript problem with the plugins ?
That is, i cant use Facebook like + share + like box at the same time.
 
hello, Nice thread

i have some, here is one :

Add Google+ button to your posts automatically :


Simply paste the code below into your functions.php file. Once you saved the file, the Google+ button will be automatically displayed below your posts.

Code:
add_filter('the_content', 'wpr_google_plusone');
function wpr_google_plusone($content) {
    $content = $content.'<div class="plusone"><g:plusone  size="tall"  href="'.get_permalink().'"></g:plusone></div>';
    return $content;
}
add_action ('wp_enqueue_scripts','wpr_google_plusone_script');
function wpr_google_plusone_script() {
    wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null);
}
------------------------------------------------

but am looking for a code that would add a prefix to all the links in my postes, any code or a plugin ?
 
Here's another popular one. Remove unnecessary links from header by sticking this in functions.php:


Code:
/* remove clutter from head */
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
 
looking for more :)
Can you sort out the problem with Facebook javascript problem with the plugins ?
That is, i cant use Facebook like + share + like box at the same time.

This is not a Wordpress issue. Could you please provide a link to check this problem?

---------- Post added at 03:20 PM ---------- Previous post was at 03:20 PM ----------

looking for more :)
Can you sort out the problem with Facebook javascript problem with the plugins ?
That is, i cant use Facebook like + share + like box at the same time.

Here's another popular one. Remove unnecessary links from header by sticking this in functions.php:


Code:
/* remove clutter from head */
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);

Awesome tip! I've added to the original post.
 
Status
Not open for further replies.
Back
Top