I have created a custom shortcode and can get the information to output, however it does not show up where I have placed it in the content hierarchy – it always prints at the top of the post/page. Any clue as to why this may be happening?
in my functions.php:
function sc_pdf($atts, $content = null) {
$pdfname = the_field('pdf_title');
$pdfimage = the_field('pdf_file');
$pdflink = the_field('pdf_thumbnail');
return '<p>'.$pdfname.'</p><p>'.$pdfimage.'</p><p>'.$pdflink.'</p>';
}
add_shortcode("peedeef", "sc_pdf");
Since you are using the_field method, I assume you use ACF plugin.
You should use
get_fieldinstead ofthe_fieldsincethe_fieldwill output the specified field.