Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #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}.php

    I 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

    #1192696

    Hi 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,
    Nikko

    #1192703

    Thanks, 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

    #1192712

    Hi 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,
    Nikko

    #1192743

    Ok thanks!! I’ll try and in case get back to you. It seems quote clear

    #1192817

    Hi elenapoliti,

    You’re welcome, just let us know your feedback :)

    Best regards,
    Nikko

    #1192920

    I 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.php

    I 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?
    Thanks

    #1193070

    Hi elenapoliti,

    Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    1. Install and activate ” Temporary Login Without Password “.
    2. Go to ” Users > Temporary Logins ” on the left-side menu.
    3. Click ” Create New “.
    4. 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 ).
    5. Click ” Submit “.
    6. 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,
    Nikko

    #1193447

    Hi 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”

    #1193788

    Hi 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,
    Nikko

    #1194058

    Thanks, 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

    #1194064

    Sorry, just tried to disable the ALB for the custom post type but still didn’t work..

    #1194134

    Hi 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,
    Nikko

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.