• Hi,

    I’m using a theme with an integrated portofolio. I would like to change the link of the portfolio to a custom URL instead of the_permalink.

    Currently the code that looks up the_permalink looks like this:

    <a href="<?php the_permalink() ?>" class="ci-keyimage-link" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">

    Is it possible to make a change to the code so WordPress gets the URL from a custom field instead of the_permalink field?

    Full code:

    <?php
        $options = get_option('ci_theme_options');
        $options_homepage = get_option('ci_homepage_options');
    
        if(isset($options['ci_portfoliokeybgcolor']) && $options['ci_portfoliokeybgcolor'] != '') {
            $ci_portfoliokeybgcolor = "background: #".$options['ci_portfoliokeybgcolor'].";";
            print "
                <style>
                    a:hover .ci-cover {background-color: #".$options['ci_portfoliokeybgcolor'].";}
                </style>
            ";
    
        } else {
            $ci_portfoliokeybgcolor = "";
        }
    
    ?>
    <div class="ci-content-positioner ci-content-positioner-no-top ci-content-positioner-no-bottom">
        <div class="ci-separator-3"></div>
        <h3 class="ci-hl-portfoliosection">
            <?php
            if(isset($options_homepage['ci_portfoliosectionhl']) && $options_homepage['ci_portfoliosectionhl'] != '') {
                echo $options_homepage['ci_portfoliosectionhl'];
            } else {
                echo __( 'Recent work', 'ciframework' );
            }
            ?>
        </h3>
    </div>
    <ul id="ci-source" class="ci-portfolio ci-portfolio-overview">
        <?php
        $count = 1;
        $query = new WP_Query();
        $query->query('post_type=portfolio&posts_per_page=-1');
        if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
    
    		$ci_portfolio_meta = get_post_custom($post->ID);
    		$keyimageurl = $ci_portfolio_meta['ci_portfolio_meta_keyimg_1'][0];
    
    		if(isset($ci_portfolio_meta['ci_portfolio_meta_keyimg_2'][0])) {
    			$keyimagezoom = true;
    			$keyimagezoomurl = $ci_portfolio_meta['ci_portfolio_meta_keyimg_2'][0];
    		} else {
    			$keyimagezoom = false;
    		}
    		?>
    		<li id="entry-id-<?php echo the_ID(); ?>" class="ci-portfolio-entry" data-id="<?php echo the_ID(); ?>">
    			        <?php
    			        if($keyimagezoom) : ?>
    						<a href="<?php echo $keyimagezoomurl ?>" class="ci-keyimage-link ci-colorbox">
    							<div class="ci-cover ci-zoom-cover">
    							</div>
        				        <h2 style="<?php echo $ci_portfoliokeybgcolor; ?>"><?php the_title(); ?></h2>
    					<?php else: ?>
    						<a href="<?php the_permalink() ?>" class="ci-keyimage-link" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    							<div class="ci-cover ci-detailpage-cover">
    							</div>
        				        <h2 style="<?php echo $ci_portfoliokeybgcolor; ?>"><?php the_title(); ?></h2>
    					<?php endif; ?>
    					<img src="<?php echo $keyimageurl ?>" class="ci-keyimage" alt="<?php the_title(); ?>" />
    				</a>
    			</li>
    		<?php endwhile; ?>
    	<?php endif; ?>
    	<div class="ci-clear"></div>
    </ul>

  • The topic ‘Change the_permalink to custom field URL’ is closed to new replies.