0

Only catname works. but how can I show other value? here the full code: https://pastebin.com/RweNnSP0

image code

  • Please paste the code as text and not as an image. Have you tried debugging this? (ie error_log($catheading); or var_dump($catheading); before the HTML) – kero May 21 '19 at 15:09
  • here the full code: pastebin.com/RweNnSP0 – Arafat May 21 '19 at 15:20
1

You haven't properly output them. You've closed the PHP tags after this:

), $atts));?>

But, if you want to output a PHP variable you need to open them again, otherwise the text will just be interpreted as HTML. You also need to explicitly echo it. So, for $catheading as an example, you need to output it like this:

<h3><?php echo $catheading; ?></h3>

Also, using extract() is considered bad practice, because it obscures where variables are coming from. You should omit it and just use the $atts array to access the values:

<h3><?php echo $atts['catheading']; ?></h3>
| improve this answer | |
  • hi, thanks for the help. I already try this and not working: pastebin.com/RweNnSP0 – Arafat May 21 '19 at 15:30
  • You're still using extract(). So if you don't manually pass the value to the shortcode then a default value for $atts['catheading'] won't exist. You need to put the return value of shortcode_atts() back into $atts. – Jacob Peattie May 21 '19 at 15:35
  • hi I remove extract but I got this problem not showing catheading background url: code updated: pastebin.com/RweNnSP0 please can you tell me whats wrong with the code. – Arafat May 21 '19 at 21:15
  • You're using $plistshortcode = shortcode_atts, which means you need to use $plistshortcode['imgbg'], not $atts['imgbg']. – Jacob Peattie May 22 '19 at 1:14
  • oh, now its working thanks for your help. – Arafat May 22 '19 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.