Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
James Burke

Shortcode is not displaying content

We have a shortcode in our functions and we are able to select the shortcode from the Admin Columns options but it does not print anything. The shortcode we are trying to print is below.

Any idea as to why it’s not displaying the author email address?

Even when we modify the shortcodeo output a hardcoded string, nothing displays.

function author_email_shortcode()
{
ob_start();

// We get the author ID outside loop.
global $post;
$author_id = $post->post_author;

// Now get the author ID inside loop.
$author_id = get_the_author_meta(‘ID’);

$output = get_the_author_meta(‘user_email’, $author_id);

ob_end_clean();
return $output;
}
add_shortcode(‘author_email’, ‘author_email_shortcode’);

We have confirmed when using the shortcode “<?php echo do_shortcode( ‘[author_email]’ );?>” does print the users email but nothing displays when we select the shortcode for the column.

Any idea what we are missing in this shortcode to have it print the persons email address?

3 months, 3 weeks ago
Stefan van den Dungen Gronovius
Developer

Can you tell me or send me a screenshot of the setup of the columns? I suspect that the content contains your shortcode? relying on the global in your case, might also be the cause of the issue.

3 months, 3 weeks ago
James Burke

trying one more time.

See here: (add ://)
https i.postimg.cc/Z4Z069dW/test. png
https i.postimg.cc/Wbb2CkGS/shortcode. png

3 months, 3 weeks ago
Stefan van den Dungen Gronovius
Developer

Thanks, I tried your shortcode and in the column does give me the right value in the column when I use it in my content. The key is that the selected shortcode in the column is used in the Content of your page. For each found (matching) shortcode in the post content, it will render the value in the column.

3 months, 3 weeks ago
James Burke

I see. Is there a way around this?

Currently we aren’t using the content to display this email address.
Perhaps there is a hook or function we can use to make this display programmatically?

3 months, 3 weeks ago
Stefan van den Dungen Gronovius
Developer

Sorry, there is no way to change the way this column works, it can only parse the content.
But since that shortcode for a post will always show the email of the author of the post, why not use our Author column and set the display to ‘User email’? I suspect that this is exactly what you’re trying to display on the table.

3 months, 3 weeks ago
James Burke

Got it. Thank you.

3 months, 2 weeks ago

You must be logged in to reply to this topic.