Join Free
+ Reply to Thread
Results 1 to 4 of 4
  1. #1

    WP Theme Customization Question: Adding External Link Button

    Hi everyone,

    So this is definitely an off-topic customization question, but the theme I am using has little support for this type of question and the theme author won't answer customization questions.

    I am using a pinterest style theme and wish to add an external link button (which would include a link to the retailers product page) on the pins. The post page already has a spot for this button, basically located above the content near the title, and you add the external link in a custom field when adding new post.

    I have found the code for this button in the single.php file, but when I move the code and put it under the excerpt (for the post) on the pinbox.php file, it includes the post title. I have attempted to alter the code, by removing certain lines, but the result is usually a blank page or the code alter some other parts of the pin.

    I need some help figuring out how to eliminate that code so that it only adds the button to that spot.

    Here is what I have identified to be the php code that includes the button and external link:

    PHP Code:
    <?php 
                            $external_link 
    get_post_meta($post->ID'external_link'true); 
                            
    $external_link_title get_post_meta($post->ID'external_link_title'true);
                            
                            
    $pinthis_quote_text get_post_meta($post->ID'quote_text'true);
                            
    $pinthis_quote_author get_post_meta($post->ID'quote_author'true); 
                        
    ?>
                        <?php if (has_post_format('quote') && $pinthis_quote_text != '') { ?>
                        <blockquote class="quote-block clearfix">
                            <p class="quote-text"><?php echo $pinthis_quote_text?></p>
                            <?php if ($pinthis_quote_author != '') { ?>
                            <p class="quote-author"><?php echo $pinthis_quote_author?></p>
                            <?php ?>
                        </blockquote>
                        <?php } else { ?>
                        <h3 class="title-3 <?php if ($external_link && '' != $external_link) { ?>have-button<?php ?>">
                            <?php if ($external_link && '' != $external_link) { ?>
                                <a href="<?php echo pinthis_addScheme($external_link); ?>" class="button button-color-1 button-size-small fright" target="_blank" rel="nofollow">
                                    <?php 
                                        
    if ($external_link_title && '' != $external_link_title) {
                                            echo 
    $external_link_title;
                                        } else {
                                            echo 
    str_replace('http://'''$external_link);        
                                        }
                                    
    ?>
                                </a>
                            <?php ?>
                            <a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
                        </h3>
                        <?php ?>
    You might already be able to tell, but I am using the WP Theme "PinThis".

    Any thoughts or suggestions would be much appreciated.

    Thanks in advance,

    Robert

  2. #2
    The code you want to remove is the title?

    That's this:

    HTML Code:
    <a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
    You should be able to remove that without causing problems.

    The remainder of the code, which appears to be the button, is still wrapped in an H3 tag.

    If you're getting a blank page with your testing, it's likely that you broke the PHP and are causing an error.

    It seems to me that you should be able to take this block of code to put this button somewhere, assuming it's in a location that supports the variables it uses.

    PHP Code:
    <?php if ($external_link && '' != $external_link) { ?> 
                                <a href="<?php echo pinthis_addScheme($external_link); ?>" class="button button-color-1 button-size-small fright" target="_blank" rel="nofollow"> 
                                    <?php  
                                        
    if ($external_link_title && '' != $external_link_title) { 
                                            echo 
    $external_link_title
                                        } else { 
                                            echo 
    str_replace('http://'''$external_link);        
                                        } 
                                    
    ?> 
                                </a> 
                            <?php ?>

  3. #3
    Hi jangro, I am making some progress, based on your suggestions, but still have some issues to work out...

    Here is the code I am using:

    PHP Code:
    <?php 
                            $external_link 
    get_post_meta($post->ID'external_link'true); 
                            
    $external_link_title get_post_meta($post->ID'external_link_title'true);
                            
                        
    ?>
                        <?php if ($external_link && '' != $external_link) { ?>
                                <a href="<?php echo pinthis_addScheme($external_link); ?>" class="button button-color-1 button-size-small fright" target="_blank" rel="nofollow">
                                    <?php 
                                        
    if ($external_link_title && '' != $external_link_title) {
                                            echo 
    $external_link_title;
                                        } else {
                                            echo 
    str_replace('http://'''$external_link);        
                                        }
                                    
    ?>
                                </a>
                            <?php ?>
    I inserted the code below the title and above the excerpt:

    PHP Code:
    <div class="title">
                    <h2 class="title-2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                </div>
    <?php 
                            $external_link 
    get_post_meta($post->ID'external_link'true); 
                            
    $external_link_title get_post_meta($post->ID'external_link_title'true);
                            
                        
    ?>
                        <?php if ($external_link && '' != $external_link) { ?>
                                <a href="<?php echo pinthis_addScheme($external_link); ?>" class="button button-color-1 button-size-small fright" target="_blank" rel="nofollow">
                                    <?php 
                                        
    if ($external_link_title && '' != $external_link_title) {
                                            echo 
    $external_link_title;
                                        } else {
                                            echo 
    str_replace('http://'''$external_link);        
                                        }
                                    
    ?>
                                </a>
                            <?php ?>
                <div class="excerpt">
                    <?php pinthis_excerpt(20); ?>
    </div>
    Here is what it looks like:

    http://admin.hrthub.com/wp-content/u...dingButton.png

    As you can see, the excerpt portion is shifted around the button, which is one thing that needs to be adjusted, the other is how to center it, as everything I test seems to have the button shifted all the way to the right.

    Is this something maybe a <div> tag can fix? I am not a php coder at all, but looking through the .php files I see the title, excerpt, and meta data have special <div> tags.

  4. #4
    yes, that a tag seems to be inheriting an float:right style. Put a div around it, and that may fix it. Or you can assign a style to it that will make it clear any float CSS.

    It's impossible to tell exactly what style is causing it from a screenshot, but you're on the right track.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
coupons | coupons and deals