• Avantart

    (@avantart)


    I took over website adminstration where OceanWP and ACF are used. All modules are uptodate (WP, ELEMENTOR, OCEANWP, ACF)
    1) CPT “Artikel” is registered, fieldgroup is defined and working: items can be entered, all entries are displayed:
    https://www.stricktiger.de/artikeluebersicht/
    2) “Read more” – links targets to https://www.stricktiger.de/artikel/boheme/
    there the header and footer are displayed, content is empty
    3) childtheme => partials => folder “artikel” exists with the typical files

    I do not understand where the display of a single entry has to be defined. Please explain the structure of integrating the output of CPT / fieldgroups / entries

    I am helpless in the moment , thanks in advance, Connie

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Shahin

    (@skalanter)

    Hello @avantart,

    Thank you for reaching out,

    For your CPT Artikel, WordPress looks for a template named single-artikel.php in your child theme. If it doesn’t exist, it falls back to single.php or index.php. That’s why your header and footer appear, but the content is empty.

    To display single entries correctly, the template should be customized in your child theme. You can either place the main CPT template in the root of your child theme or use the child-theme/partials/artikel/ folder for partial templates. This ensures that any changes are preserved during theme updates.

    Alternatively, you can use a plugin from the WordPress repository to create a custom template for your CPTs.

    In short, the content isn’t showing because the template responsible for single entries hasn’t been configured to display the CPT fields yet. Once this is set up in the child theme, your articles will display correctly.

    Hope it helps,
    Best Regards

    Thread Starter Avantart

    (@avantart)

    Thank your for your help!
    Does ist mean you can use either one main CPT template or partials, but if both exists in the child theme it won’t work?

    Connie

    Shahin

    (@skalanter)

    Hello @avantart,

    You’re welcome, glad to help.

    To clarify, WordPress will always look first for the main template file (for example, single-artikel.php) in your child theme. Inside that template, you can either write all the markup directly or call partials from your partials/artikel/ folder to keep things structured.

    So it’s not either-or. Both can exist and work together:
    – The main CPT template is required, since WordPress needs a starting point.
    – The partials are optional and are just included from inside that main template.

    If only partials exist but no single-artikel.php, WordPress won’t know to load them, and you’ll see just the header and footer with no content.

    Hope it helps,
    Best Regards

    Thread Starter Avantart

    (@avantart)

    Shahin, thank you so much. This explains me why no content was shown even that the partials existed!

    You are a great help!
    Cheers, Connie

    Thread Starter Avantart

    (@avantart)

    is there a plain example for adding CPT to the childtheme?
    Or can I use index.php as “template” for single-{cpt}.php and modify the “get_template_part()” ?

    In the moment I do not see wood because there are too many trees ;=(

    Shahin

    (@skalanter)

    Hello @avantart,

    Thank you for the update,

    The solution to achieve it is customization, and it needs familiarity with PHP, if you are unfamiliar with PHP, you can contact a PHP expert. To do this, first, you need to use the child theme. You can copy the metafile from the partials folder in the child theme following the same path and then make the necessary changes. Or, if you prefer to do it without coding, you can search the WordPress repository for a plugin that fits your needs: https://wp.org/plugins/

    However, if you want to create those templates yourself, the following method is commonly used in OceanWP. You can copy and edit examples from sections like Blog.

    By using FTP or cPanel access (if didn’t use the localhost), Go to this directory: wp-content\themes\oceanwp\partials Find your template which you want to customize and copy that template file(in your case, for example, you need to change the date on the blog page, so you need to use the blog template(s): https://i.postimg.cc/brv9gn9s/image.png).

    Then head over to the same path on the child theme. There isn’t an entry folder as a default on your child theme, so you need to create a new one(one time).

    Example: If you want to change the HTML tags structure in the single blog post featured image for standard post format, all you need in this step is the following:

    1. Head over to your Site Root > wp-content > themes > oceanwp > partials> single > media path.
    2. Then, find the “blog-single.php” file and copy this file.
    3. After that, go back to the themes folder (wp root > wp-content > themes) and go to the oceanwp-child-theme-master folder.
    4. Create a new folder with the “partials” name in the child theme.
    5. Go to the /partials/ folder and create a new folder with the “single” name.
    6. Go to the /single/ folder and create a new folder with the “media” name.
    7. Go to the /media/ folder and paste the “blog-single.php” file here.

    Also, read these links as well:
    1. https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/
    2. https://developer.wordpress.org/reference/functions/get_template_part/
    3. https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types
    4. https://developer.wordpress.org/reference/functions/register_post_type/

    Hope it helps,
    Best Regards

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘CPT – display single entry’ is closed to new replies.