• Can you please help me guys. I want to get data from database and put it inside a link. all i get is errors. here’s my code

    <?php

    global $wp_query;
    $postid = $wp_query->post->ID;

    $links = get_metadata(‘post’,$postid,’vlink_1′,’false’);
    foreach($links as $link)
    {
    echo “title of the link
    echo “

    }
    ?>

    I want to add my 7 database inside a link.

    example:

    Link1
    Link2
    Link3

Viewing 5 replies - 1 through 5 (of 5 total)
  • What are the errors that you’re getting?

    The way to see what you’re getting back is to do something like this:

    echo "<pre>";
    var_export ($links);
    echo "</pre>";

    That will show you exactly what you’re getting back, and then you can see if that’s the problem or not.

    Try reposting or editing your post and enclose the code with backticks (click the code button) so we can see the code properly. As it is, the code has errors because it is missing semicolons after the echo statements:

    <?php
    
    global $wp_query;
    $postid = $wp_query->post->ID;
    
    $links = get_metadata('post',$postid,'vlink_1','false');
    foreach($links as $link)
    {
    echo "title of the link";
    echo "
    ";
    }
    ?>

    Thread Starter lanztuss12

    (@lanztuss12)

    thanks for your help guys. but i need is, i want to put it inside a link. the “title of the link” must be inside href. how can i fix that errors?

    Thread Starter lanztuss12

    (@lanztuss12)

    this one works in a single

    <?php

    global $wp_query;
    $postid = $wp_query->post->ID;

    echo ‘<a href=”‘;
    echo get_metadata(‘post’,$postid,’vlink_1′,’true’);
    echo ‘” target=”_blank”>’;
    echo ‘Openload.io’;
    echo ”;
    ?>

    But I need multiple array. I want to get all the links in my database with same metakey

    Moderator keesiemeijer

    (@keesiemeijer)

    @lanztuss12

    Please post code or markup snippets between backticks ( ` ) or select the code and use the code button. As it stands, your posted code may have been permanently damaged/corrupted by the forum’s parser.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘About foreach argument’ is closed to new replies.