Skip to main content
1 of 3
bear
  • 13
  • 1
  • 6

How to share post?

I found this code that will share my post in social medias but right now it share the whole page and not the individual post. How do I make it share only the individual post? I know its something with the url i the code but dont know what to change it to.

This is the loop for the post.

<div class="tm_category_box_home5">
        <?php $count = 1; ?>
        <?php if ( have_posts() ) : ?>
             
            <!--<the loop>-->
            <?php $wp_query = new WP_Query( array( 
                                                "cat" => "1", 
                                                "posts_per_page" => "15", 
                                                "post_type" => "post",
                                                "paged" => get_query_var('paged') ? get_query_var('paged') : 1
                                                )                                               
                                        );
            while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
            
            <div <?php post_class(); ?>>
            
                <!--<cat title>-->
                <div class="tm_catpost_titles">
                        <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
                            <h1 class="tmpost-<?php the_ID(); ?>">
                            <?php $tit = the_title('','',FALSE); echo substr($tit, 0, 150); if (strlen($tit) > 150) echo " ..."; ?>
                            </h1>
                        </a>
                </div>
                <!--</cat title>-->     
<!--<cat item>-->
                <div class="tm_cat_item">
                    <div class="tmpost-<?php the_ID(); ?>-item">
                        <div id="catpostup">    
                        <div class="tm_catpost_item_1">
                        <?php _e('Av', 'tm_myid_text'); ?> <?php the_author(); ?>
                        </div>

                        <div class="tm_catpost_item_2">
                        I <?php $category = get_the_category(); echo $category[0]->cat_name; ?>
                        </div>
                        
                        <div class="tm_catpost_item_3">
                        <?php the_time('M jS, Y') ?>
                        </div>
                         

                    </div>
</div>
                </div>
                <!--</cat item>-->
                
                <!--<cat image>-->
                <div class="tm_cat_image">
                <?php if (has_post_thumbnail()) { ?>
                    <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                    <?php the_post_thumbnail( 'Full' ); ?>
                    </a>
                <?php } else { ?>
                <?php } ?>
                </div>
                <!--</cat image>-->
                
                <div class="tm_cat_desc_home5">
                    <div class="tmpost-desc">
                    <?php the_content(); ?>
                    </div>

                    <div class="tm_cat_readmore">
 
                        <div class="tmpost-readmore">
                            <a href="<?php the_permalink() ?>" target="_blank">
                                 <?php comments_number(__('(0) Kommentarer ', 'tm_myid_text'), __('(1) Kommentar', 'tm_myid_text'), __( '(%) Kommentarer', 'tm_myid_text') );?> 
                            </a> 
                                    
                
                        </div>

                    </div>
                <!-- I got these buttons from simplesharebuttons.com -->
<div id="share-buttons">
 
<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=http://www.alskadehem.se" target="_blank"><img src="http://alskadehem.se/wp-content/uploads/2014/04/facebook.png" alt="Facebook" /></a>
 
<!-- Twitter -->
<a href="http://twitter.com/share?url=http://www.alskadehem.se&text=Simple Share Buttons" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/twitter.png" alt="Twitter" /></a>
 
<!-- Google+ -->
<a href="https://plus.google.com/share?url=http://www.alskadehem.se" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/google.png" alt="Google" /></a>
 
<!-- Tumblr+ -->
<a href="https://plus.google.com/share?url=http://www.alskadehem.se" target="_blank"><img src="http://alskadehem.se/wp-content/plugins/simple-share-buttons-adder/buttons/somacro/tumblr.png" alt="Tumblr" /></a>
 
<!-- Pinterest -->
<a href="javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());"><img src="http://www.simplesharebuttons.com/images/somacro/pinterest.png" alt="Pinterest" /></a>
 
<!-- Email -->
<a href="mailto:?Subject=Simple Share Buttons&Body=I%20saw%20this%20and%20thought%20of%20you!%20 http://www.alskadehem.se"><img src="http://www.simplesharebuttons.com/images/somacro/email.png" alt="Email" /></a>
 
</div>
                </div>
            </div>
<?php if ($count == 1) : ?>
<div id="ad"></div>
<?php endif; $count++; ?>
            <?php endwhile; ?>
            <!--</the loop>-->
 
bear
  • 13
  • 1
  • 6