So I've created a custom post type filled with Advanced Custom Fields only. There is no "content".

I've created a single-custom.php, content-custom.php and archive-custom.php.

All looking nice and working perfect.

What I would like to achieve is to create a shortcode (I believe) for the archive-custom.php, so I can display the content of the archive-custom.php content on another part of my website, let's say on two different pages, with additional content.

At first i thought i create a short code for the custom post type it self by this example: Themed custom loop using shortcodes

But it's getting rather a very long short code. And everything I've solved before in content-custom.php, I have to start over in functions.php and "re-div-ify" it in the shortcode.


Most probably you need a bunch of divs etc duplicated in both archive-custom.php and the shortcode. Identify those divs, and move them into a new template file in your theme, e.g. in part-archive-custom.php. Then, delete them from archive-custom.php and add a call to get_template_part('part-archive-custom'); instead.

Do the same inside your shortcode.

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.