WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
Unable to create custom field link in custom template (2 posts)

  1. twowithink
    Member
    Posted 1 year ago #

    Please help! I have setup a custom field to link to the press release associated with each deal on this page: http://www.vfpfinancial.com/news/deal/

    The problem is that the links are not working and my PHP knowledge is very basic. The added div is:

    <div class="news-deal-link">

    Here is the template code:

    <?php
    /*
    Template Name: funding deals
    */
    ?>

    <?php get_template_parts( array( 'parts/shared/html-header', 'parts/shared/header' ) ); ?>

    <h2 class="post-title"><?php the_title(); ?></h2>

    <?php
    //$temp = $wp_query;
    //$wp_query= null;
    //$wp_query = new WP_Query();
    $args = array();
    $args['post_type'] = 'funding_deal';
    $args['orderby'] = 'funding_date';
    $args['order'] = 'DESC';
    //$args['limit'] = 10;
    //$args['paginate'] = TRUE;

    $Q = new GetPostsQuery($args);
    $results = $Q->get_posts();

    //print_r($results);

    //$wp_query->query($args);
    //while ($wp_query->have_posts()) : $wp_query->the_post();
    //$post = $wp_query->post;
    foreach($results as $i => $p):
    ?>
    <?php if($i>1 && $i % 3 === 0): ?>
    <div class="cf"></div>
    <?php endif; ?>
    <div class="news-deal">
    <h2 class="news-deal-title"><?php print $p['post_title'] ?></h2>
    <div class="news-deal-amount"><?php print $p['funding_amount'] ?></div>
    <div class="news-deal-bottom">
    <div class="news-deal-desc"><?php print $p['funding_desc'] ?></div>

    <div class="news-deal-link">
    " target="_blank">Press Release
    </div>

    <div class="news-deal-date"><?php print $p['funding_date'] ?></div>
    </div>

    </div>

    <?php endforeach; ?>
    <?php //endwhile; ?>
    <?php if(function_exists('wp_paginate')) {
    //wp_paginate('range=4&anchor=2&nextpage=Next&previouspage=Previous');
    } ?>

    <?php //$wp_query = null; $wp_query = $temp;?>

    <?php get_template_parts( array( 'parts/shared/footer','parts/shared/html-footer') ); ?>

    Thank you for any help!!!

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    Please format your code correctly in your post -- it makes it much easier to read and it ensures that nothing gets lost.

    If you're using GetPostsQuery, there are numerous examples in the wiki of how to use it. Each item returned in the result set includes a "permalink" key, e.g.

    <a href="<?php print $p['permalink'] ?>">Click here...</a>

    I would strongly recommend that you simplify this while testing and avoid all the potential pitfalls of extra if-statements -- just print your results as simply as possible to figure out how to make your anchors work. Looking at the above, I'd say it's an HTML problem, not anything with the CCTM or even with PHP.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic