This topic has 3 replies, 2 voices, and was last updated 9 years by sharmstr.

  • Author
  • #85226
     alvinhy
    Participant

    Hello,

    I have a page with the blog masonry, and would like the image to link to a custom field using Types plugin.

    I tried to edit the /page-parts/page-content-masonry.php at around line 150 I added:

     

    $link = get_post_meta($the_id, ‘wpcf-website’, true);

    echo ‘<a href=”‘. $link .'” class=”element-wrap”>’

     

    but then once I save it the image does not link to the custom field I set, instead it just refreshes the page (does nothing). Am I doing something wrong?

    Thanks.

     

    Attachments:
    You must be logged in to view attached files.
    #85231
     sharmstr
    Moderator

    How have you set $the_id? Echo out $link to make sure $link is what you think it is.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #85306
     alvinhy
    Participant

    Hello there,

    I got it to work by using:
    $link = get_post_meta($post->ID, 'wpcf-website', true);

    Another question is, is it possible to only show this code only for IMAGE post type formats?

    COPY CODE
    		<?php		
    			$cfsource = get_post_meta($post->ID, 'wpcf-source', true);
    			echo '<div class="cflink"><a href="'. $link .'" target="_blank">Get it at '. $cfsource .' Today</a></div>';	
    		?>	
    #85320
     sharmstr
    Moderator

    use this https://codex.wordpress.org/Function_Reference/get_post_format

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?