Tagged: Custom Post Type, enfold
-
AuthorPosts
-
March 12, 2020 at 4:07 pm #1192665
Hi, I have a question. I should prepare a site with 3 different CPT. Consider that the site doesn’t need the Blog section. Since I am completely new in creating custom post type, I would like to know which is the best way to achieve it.
I managed to add the CPT in the admin section (either by using the plugin or by simply adding the function in functions.php) together with their taxonomies. I also managed to enable the Avia Layout Builder n the custom post type as by Enfold documentation. However I realized that I don’t need it as I have to use custom fields (with ACF). Hence, in order to add the custom fields in the page I imagine I should copy the following file to my child theme:
single.php -> which becomes single-{post-type}.php
so I should have 3 different files for it , let’s say:
single-{post-type-1}.php
single-{post-type-2}.php
single-{post-type-3}.phpI tried to modify the file but I didn’t succeed in doing it. Have you any suggestion?
Another possibility is to create a function for each custom field to use it as a shortcode, but since I have many that would be too much work. Maybe it’s easier to add them directly in the single-post.php file.
I read that there are several forum discussion about how to include the custom post types in the portfolio grid, so for that issue I may try to go through the forum before coming back to you. However I need to solve the issue above first
Thanks
March 12, 2020 at 5:43 pm #1192696Hi Elena,
You should have 4, you’ll need to have the default single.php aside from the 3 single-{post-type}.php.
I think it’s correct and should work according to the WP Codex: https://developer.wordpress.org/themes/basics/template-hierarchy/
Can you give us a link for each post type mentioned? you can post this in private content.Best regards,
NikkoMarch 12, 2020 at 5:49 pm #1192703Thanks, I will do it. But I need to know which part of the original single.php I can overwrite. I did it already with a copy of the page.php, but I am not sure about the single.php. Should I cancel all the first part concerning the blog?
i.e.
if(avia_get_option('frontpage') && $new = avia_get_option('blogpage')) { $title = get_the_title($new); //if the blog is attached to a page use this title $t_link = get_permalink($new); $t_sub = avia_post_meta($new, 'subtitle'); } if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title(array('heading'=>'strong', 'title' => $title, 'link' => $t_link, 'subtitle' => $t_sub));
and write the whole new html/php just after
do_action( 'ava_after_main_title' );
???Thanks
March 12, 2020 at 6:07 pm #1192712Hi elenapoliti,
I’m not really sure what you’re trying to achieve so I can’t really say for sure which to remove but if you only want to change the content area, then you’ll only need to replace:
get_template_part( 'includes/loop', 'index' );
replace with something like:
get_template_part( 'includes/loop', 'posttype1' );
Then copy loop-index.php (inside includes folder) and paste it in the includes folder of your child theme and rename it to loop-posttype1.php and tweak it.
Hope this helps.Best regards,
NikkoMarch 12, 2020 at 8:18 pm #1192743Ok thanks!! I’ll try and in case get back to you. It seems quote clear
March 13, 2020 at 3:36 am #1192817Hi elenapoliti,
You’re welcome, just let us know your feedback :)
Best regards,
NikkoMarch 13, 2020 at 5:50 pm #1192920I am sorry but I probably miss something about the whole thing.
I created a custom post type named ‘appartamenti’
I added to my child them a file single-appartamenti.php and the loop-index.php which was renamed in includes/loop-appartamenti.phpI tried to add a new post, leaving the content empty, while I added some strings in the single-appartamenti.php to see if they appear in front-end, but nothing happened. I thought I did something wrong, so I deleted the previous files and simply added a single-appartamenti.php in which I wrote a basic code with loop (as by wp examples) like the following:
<?php if ( !defined('ABSPATH') ){ die(); } global $avia_config; get_header(); ?> <div id="content"> <div id="inner-content" class="wrap test"> <main id="main" class="test" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class('test'); ?> role="article"> <p>THIS IS A TEST</p> </article> <?php endwhile; ?> <?php else : ?> <article id="post-not-found" class="hentry cf"> <h1>Oops, Post Not Found!'</h1> </article> <?php endif; ?> </main> </div> </div> <?php get_footer();
Still nothing happened. I mean in the front-end I see my article completely empty! Am I doing something completely wrong?
ThanksMarch 14, 2020 at 8:48 am #1193070Hi elenapoliti,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( to be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create an admin user and post the login credentials in the “private data” field.Also if Theme Editor is not available please provide FTP access, so we can check on the child theme files.
Best regards,
NikkoMarch 16, 2020 at 11:53 am #1193447Hi I just uploaded it on a test server. Below the access. Consider that it is a trial. Hence I created just 1 over 3 Custom Post types and added just very few custom fields with ACF.
The CPT I created is called “Appartamenti”March 17, 2020 at 1:17 pm #1193788Hi elenapoliti,
Thanks for giving us both admin and FTP access.
After checking it, I noticed that you are using Advanced Layout Builder in the custom post type, in which after enabling ALB it won’t be using the single-posttype.php file, instead it’s using template-builder.php file in the unfold theme.
You can use this filter avf_template_builder_content if you want to make modifications to the content.Best regards,
NikkoMarch 18, 2020 at 10:04 am #1194058Thanks, so I have 2 possibilities: disabling ALB from the custom post-types; or using the filter you suggest.
How can I use the avf_template_builder_content filter? I am not sure.
Thanks a lot for the support
March 18, 2020 at 10:20 am #1194064Sorry, just tried to disable the ALB for the custom post type but still didn’t work..
March 18, 2020 at 3:31 pm #1194134Hi elenapoliti,
I have checked it and the reason it does not work is because it still tagged as using ALB :(
I have created another appartamenti page and you should see it working properly (refer to link in private content).Best regards,
NikkoMay 18, 2023 at 3:45 pm #1407848Hi Support,
I am also having the same issue, can anyone help me regarding this.
May 19, 2023 at 1:17 am #1407886Hi NicomIT,
Yes, we would like to help you, please create a separate thread and give us further information, also include a link to this thread.
Best regards,
Nikko -
AuthorPosts
- You must be logged in to reply to this topic.