Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9256911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:05:25+00:00 2026-06-18T12:05:25+00:00

I have searched this problem for a while now, maybe it is simple or

  • 0

I have searched this problem for a while now, maybe it is simple or maybe not. I could not figure out how to get this to work.

My goal outcome would be a hyperlink related to the post meta with some styling like so.

<a href="href_link" style="color: #e67300" rel="nofollow"> Check out the r_title here!</a>

The code I have is:

<?php
$rtitle1 = get_post_meta($post->ID, 'r_title', true);
$rlink1 = get_post_meta($post->ID, 'href_link', true);
    function testfunction() {

    $output .= '<a href=\"'$rlink1'\" style=\"color: #e67300\" rel=\"nofollow\">';
    $output .= ' Check out the '$rtitle1' here!</a>';

    return $output;
    }
add_shortcode('shortcode', 'testfunction');
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:05:26+00:00Added an answer on June 18, 2026 at 12:05 pm

    There are several problems with your code.

    The first problem is with string concatenation. When you want to glue strings together you need to use the concatenation operator (the dot: .):

    $end = 'a string';
    $start = 'This is ';
    $string = $start.$end;
    

    If you just juxtapose variables and strings (or any other scalar types) then you will get errors:

    $end = 'a string';
    $string = "This is "$end; // Error!
    

    The second problem is that you are using two variables ($rtitle1 and $rlink1) that are in the global scope. If you want to use global variables inside a function then you need to declare them as global inside the function:

    $globalVar = 'test';
    function test() {
      global $globalVar;
      echo $globalVar;
    }
    

    The third problem is that you forgot the ending closing parenthesis, ), for the get_post_meta() function:

    $rtitle1 = get_post_meta($post->ID, 'r_title', true;
    $rlink1 = get_post_meta($post->ID, 'href_link', true;
    

    They should be like this:

    $rtitle1 = get_post_meta($post->ID, 'r_title', true);
    $rlink1 = get_post_meta($post->ID, 'href_link', true);
    

    Before you think about asking for help you should look at the error messages that you get. If you have not seen the error message before then Google it. The best way to learn something is to find the solution on your own. Asking questions is for when you have tried finding a solution but you cannot find it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched google and SO for a solution to this problem but have not
Preface: I am sure this is incredibly simple, but I have searched this site
I have searched for this for a long time now... I am writing an
I have searched for this but nobody have the same issue.. Now I need
So I have searched for this but not finding anything about it and if
i have now since a while a systematic problem with NSStrings and appending these
I am rather new to MySQL, I have this problem, which I have searched
I have searched this topic on google a bit and seen some best practices.
I have searched this site and Google and even though the idea is pretty
I have searched for this, and i found that for api less than 12,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.