Forums

[resolved] Change link on post titles (6 posts)

  1. dsgdesigns
    Member
    Posted 2 years ago #

    I am going to put up an ecommerce site with my products displayed on the homepage. Each product will have a title and it will be a link. Each product will be a unique post. Instead of the post title linking to the post page, I would like for it to link to a page of my choosing. Is this possible?

  2. dbmartin
    Member
    Posted 2 years ago #

    Yes, but you'll have to hard-code each title link unless you want all post title links to go to the same page.

  3. dsgdesigns
    Member
    Posted 2 years ago #

    Can I do it with custom fields?

  4. dbmartin
    Member
    Posted 2 years ago #

    Possibly, depending on what you're trying to do. Without really knowing what you're attempting, I think it would go something like this:

    When writing your post, create a custom field called "title_link" in the Name field and then add whatever URL you want in the Value field.

    Then in your template file you'd write something in the LOOP along the lines of:

    <?php while (have_posts()) : the_post(); ?>
    	<div class="post" id="post-<?php the_ID(); ?>"> <!-- post -->
    		<?php $titleLink = get_post_meta($post->ID, 'title_link', true); ?>
    		<h1><a href="<?php echo $titleLink; ?>"><?php the_title(); ?></a></h1>
    		<?php the_content(); ?>
    	</div> <!-- /post -->
    <?php endwhile; ?>
  5. dsgdesigns
    Member
    Posted 2 years ago #

    Can I email you some more specifics about what I am doing? I would prefer to keep it somewhat confidential.

    If you don't want to post your email I understand. You can email me at daniel(at)dsg-designs(dot)com

  6. dbmartin
    Member
    Posted 2 years ago #

    Of course. You can contact me though the contact form on my site, just follow the link next to my gravatar.

Topic Closed

This topic has been closed to new replies.

About this Topic