HELP needed for the last step... embedding .php code

Hello Support Team,

we activated CUSTOM PRESS Plugin on our sub domain

http://aboutme.bestofthebestonly.com/

and followed diligent each step as outlined in Manual.

Now we have....

- POST TYPES
- TAXONOMIES
- CUSTOM FIELDS
- PAGE TEMPLATE

BUT

we have no clue WHERE precisely to embed the code NOR are we able to CREATE a new page e.g. for our ABOUT ME site.

We checked over and over again all explanation... we checked more than once our settings done, unfortunately we stuck heavily.

PLEASE do us the favor and check our settings WHY we aren't able to create needed new page ... what did we wrong.

Also please embed for our first POST TYPE named ABOUT ME with related Custom Field

BotBO Username

Embed code which returns the values of the custom field with the specified key from the specified post.

---> We can't find LOOP in Template to do the next step

Use inside the loop in templates and PHP code

<?php echo do_shortcode('[ct id="ct_BotBO_User_text_ab49" property="title | description | value"]'); ?>

Your kind support would enable us to do the same steps on all other Post Types the have.

Support Access granted.
Attached screenshots in case we expressed us not clearly.

Looking forward hearing from you soon.
Kind regards
Prinz

  • Michelle Shull

    Hello, Prinz!

    Okay, I've been digging, and first off, I want you to let yourself off the hook for not finding the loop. It's not where it should be, so you're doing just fine. This is MUCH trickier, because of how your theme handles single.php. Typically, we'd just slap some PHP in a copy of that file named about-me-single.php, create an archive page by copying archive.php into about-me-archive.php and calling it a day, but your theme is special. It puts the loop in other files, which are then called by single.php. Archive.php is a whole different ball of wax, we'll get to it in a minute.

    I need you to find and send me three template files. I can't get deep enough in the theme editor I can access via your network dashboard. I'm also going to ask for FTP details, so I can upload the new files I create and test them myself so the next time I report it in will be to say I've got you all hooked up.

    One bonus I gave you - I created a new About Me called This is A Test. I used the custom field shortcodes in the post content itself to make sure the right data was being posted, and they work great. This means you've got all your settings just right. I went ahead and checked through your other custom content, and it all looks excellent. Very nice work here, Prinz. I know this is pretty harrowing the first time, you jumped in with both feet and now you're an expert. :slight_smile:

    Okay! Send me the following files:
    inc/templates/template_single
    inc/templates/template_single_multi
    inc/templates/template_single_project

    You should find the /inc/ folder inside the parent Trades theme folder.

    Here's the other standard contact info stuff:
    https://premium.wpmudev.org/contact/

    Subject: "Attn: Michelle Shull"
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me. :slight_smile:

    I'm subscribed here, and my last front line shift of the day just ended (with you!) so I can hop right in and get this sorted. It may take a couple of hours, just so you're aware of the time span here.

    Thanks, Prinz! I know this has been a day, hopefully getting this all sorted can take some weight off your shoulders. :slight_smile:

  • Michelle Shull

    Heya Prinz!

    FTP kept timing out on me, so I just used the cPanel's file manager, but I've got you all hooked up.

    Here's what you need to do to reproduce what I've done for each of your custom post types.

    1. start in the /inc/templates folder of your PARENT theme. You're going to copy the content of template_single.php into a new file for each of your custom post types, like so:
    template_single-about_me.php
    template_single-goals_n_aims.php
    template_single-social_activities.php
    etc.

    2. Next, open up a notepad file to keep things simple for yourself. Working with one custom post type at a time, gather all the custom field php snippets you need.

    3. We're going to wrap those PHP snippets in some other code, so we can style these fields later. This is the bit I added to template_single-about_me.php:

    <div class="BotBOUserName"><p>BotBO Username: <?php echo do_shortcode('[ct id="ct_BotBO_User_text_ab49" property="title | description | value"]'); ?></p></div>
    <div class="BotBOCurrentCountry"><p>Current Country: <?php echo do_shortcode('[ct id="ct_Current_Co_checkbox_9e9d" property="title | description | value"]'); ?></p></div>
    <div class="BotBONarrowArea"><p>Narrowed Area: <?php echo do_shortcode('[ct id="_ct_text_5596930083ce3" property="title | description | value"]'); ?> </p></div>
    <div class="BotBOLivingSitch"><p>Personal: <?php echo do_shortcode('[ct id="_ct_textarea_55936acd40d8b" property="title | description | value"]'); ?></p></div>

    3a. Notice there are a few parts.

    *The div class creates a unique div we can style around that line.
    *The < p > tag makes the content within it a paragraph, so WordPress knows it needs to start this bit on a new line.
    *The < strong > tags make the introductory text before the PHP fires bold, so it stands out. You can change this text in the file, if you'd like, as well, I guessed here, you'll probably have better names. :slight_smile:

    4. I added these lines AFTER this line in single_template-about_me.php:

    <?php the_content(); ?>

    And BEFORE this line:

    <div class="link-pages"><?php wp_link_pages(array('before' => '<p>' . __('Pages:','loc_canon'))); ?></div>

    5. You'll want to do the same to add the PHP to echo the contents of the custom fields you want to show in each of your template_single-{your_cpt_slug_here} files. Take your time! This is tedious work, and it's easy to miss a closing slash here and there. :slight_smile: Save all of these files in inc/templates/ of your PARENT theme.

    6. Next, we're going to move over to the root of your PARENT theme folder, and make copies of single.php for each custom post type, like so: single-about_me.php.

    7. For this file, you need to change the line that points to template_single.php to point to your new template_single-{your_custom_post_slug_here}.php file instead.

    So, you'll change:

    } else {
    
            get_template_part('inc/templates/template_single');     
    
        }

    To:

    } else {
    
            get_template_part('inc/templates/template_single-about_me');     
    
        }

    Do this for each custom post type, and save all these files to the root of your PARENT theme folder.

    There are no worries here about the files you're making being overwritten when your theme updates, these files will all stay put and untouched - there are no matching files in the theme itself to overwrite the ones we're making.

    Here's my test post with all the fields showing.

    Does this give you a place to start? I can help along the way if you need me! I'll be around for another few hours tonight, and all day tomorrow.

    Have fun, Prinz!

  • Klaus

    Hello Michelle,

    WOW... that's so kind of you having forwarded us already last night the solution. We value that really much higher especially were we knew, you did this in your free time. BIG, BIG thanks for that.

    This morning took me bit longer to get my colleagues in to do the next step together... unluckily with the 'working result'. Please check our entries we did and advice us once more for the rest of the post types we have to do.

    Question 02: Wouldn't it be great having here at this area a short GUIDELINE in light grey to let user know what this area is for? How can this be arranged?

    Question 03: Promised, fussy we entered the first POST TYPE. We struggled much determine the <div class name... could also not figure out from were you took the names on it. Well, BotBOUsername was easy... but e.g. 'NarrowedArea' how did you come up with that definition? Please help as we believe we did wrong, with the result 'our BECOME Friends' does not show the entries made in ADD NEW POST.

    Question 01: Placed in the post example 'About ME'... you made.
    Question 02: Wouldn't it be great having here at this area a short GUIDELINE in light grey to let user know what this area is for? How can this be arranged?
    Question 03: Promised, fussy we entered the first POST TYPE. We struggled much determine the <div class name... could also not figure out from were you took the names on it. Well, BotBOUsername was easy... but e.g. 'NarrowedArea' how did you come up with that definition? Please help as we believe we did wrong, with the result 'our BECOME Friends' does not show the entries made in ADD NEW POST.
    Question 04: Obvious the next mistake, as we don't have 'TAXONOMY' here. We couldn't figure out our failure! Please advice... :slight_smile:
    Question 5: Open your "ABOUT ME" example once again. Taxonomy is there, but the "ADD Button" is missing. How is this solved?The
    Question 06: 'PREVIEW CHANGES' leads to 404 error... but 'View Post' works. How can this be fixed?

    Looking forward hearing from you again.
    Cheers
    Prinz

  • Michelle Shull

    Hey there, Prinz!

    You can name the divs whatever you want. Just make sure to only use letters, numbers, the dash (-) and the underscore (_) in the name. Div names can't start with a number, but they can have numbers in them. I should have mentioned that part, so sorry!

    To fix the 404, try saving your permalinks. We're popping all sorts of new pages into your site, we need to let WordPress catch up.

    I totally forgot to build in the Taxonomy, that's my bad, I'll add that in and update you with a new tutorial piece. :slight_smile:

    I'll also check your work on the pages you created. :slight_smile:

    Glad we're on the right track here! Your network is really coming along!

  • Michelle Shull

    Hey Prinz!

    Okiedou, to add the taxonomy, you'll open up your template_single-custom_type files from inc/templates, and add the PHP embed code from the taxonomy content type page in Custom Press. This is the line I used in about_me:

    <div class="aboutMeTaxonomy"><p><?php echo do_shortcode('[tax id="about_me_taxonomy" before="Posted in: " separator="| " after=""]':wink:; ?></p></div>

    I changed the default text to say "Posted in:" before the taxonomies are listed, with no text after, and a lovely bar | as a separator. You can change either of these to better suit your needs here.

    Your pages are looking good so far!

    From your message in your site, if you want to prevent users from using the area where you typed the message to me, untick the box next to "Editor" in the custom post type settings. This way, only your custom fields will show on that page. :slight_smile: Check my screenshot here.

    Also from your site, I do love to cross stitch! I've tried knitting, but I'm not very good yet. :slight_smile:

    Hope you're well, let me know if this doesn't help here. :slight_smile:

  • Klaus

    Dearest Michelle,

    first of all let me sincerely express how much we - especially me - value your support very much. Furthermore we/I do appreciate every single advice and help you give to us.

    Perhaps you're wondering, why did I not come back earlier, since your last lesson given to us. The reason is very simple: We moved our web application to a VPS server now which does indeed improve lots of things but unfortunately the move took it's while and has still some issue which has to be solved... however, my colleagues and I am since today able again to access our existing project.

    Dear Michelle that means also, we are ready for the next lesson. Before I list my question let me also state that all steps you suggested worked out perfectly; one exception our 404 issue was (not permalink) simply solved by untick POST Format box... an advice we received from your colleague Sajid.

    What we do need for today would be some advice with examples (if possible) about setting the validation rules. We researched for that but there are to many examples on the web available which irritates us more then being useful for us.

    All we know what validation is meant for... but we have no clue of its effects and how/also where precisely to place it as there are at least to option fields.

    i = ignore case, g = global, m = multiline
    Enter a regular expression to validate against or leave blank. Example for Email:
    ^[\w.%+-]+@[\w.-]+\.[A-Z]{2,4}$ i

    We are excited being taught from you for the next steps.

    Thanks in advance.
    Prinz

  • Michelle Shull

    Heya, Prinz!

    Congrats on your new server home! It's nice to have room to spread out now, isn't it? You'll get the quirks sorted, and you'll wonder why you didn't move sooner.

    And, for the less cheery part, regular expressions are above my head. Completely. I've spent hours, but they still look like sorcery to me. So, let's bring in one of our awesome SLS guys here to help translate regular expressions into plain English, and get you (and me, as a bonus) on the path to knowing more here.

    You get the basics, we use regular expressions to validate field forms, so the field recognizes if someone tries to type words in a phone number field, or doesn't enter an email address properly. A regular expression will do {fancy math} comparing the characters entered in the field to the model created in the regular expression, and reject the submission if it doesn't match. All of this is wicked cool, and super handy, but that's as far as I can go with my explanation.

    So we can help SLS help you faster, which fields are you wanting to include validation for? We can get you the regex you need. Well, the SLS guys can, I'll just be the charming intermediary here. :slight_smile:

    Thanks Prinz! I'm so impressed with how far you've come in the past few months. You're really learning a lot, and your network is coming together great. :slight_smile:

  • Klaus

    Hello Michelle,

    deep breath... astonishing and BIG thanks for your effort explaining us this subject. Now, it sounds still not that 'easy' BUT it became more sunny.

    Okay, we would need to know in which field do we have to enter an expression like

    - don't use numbers in this field
    - enter more than 8 characters
    - this type of value you entered is not possible

    Also, why and when is there i=ignore to enter, g=global and m=multi line to enter?

    Thanks for your compliment about our application. You're motivating us with that much apart from brightening our days.

    Looking forward receiving some 'basic and typical' examples.
    Bye for now...
    Prinz

    NS: Happy stitching and a pleasant rest of this weekend!

  • Jude

    Hey again Prinz

    1) don't use numbers in this field

    ^(\D*)([^0-9])(\D*)$

    2) enter more than 8 characters

    ^.*([0-9a-zA-Z_\.!@#$%^&*\(\)]{8,}).*$

    3) this type of value you entered is not possible ( exclude invalid chars )

    ^([a-zA-Z0-9_]*)([a-zA-Z0-9_].*)

    Hope that helps

    You can do a very useful study on this here
    http://regexone.com/lesson/0

    Test LIVE here

    http://www.phpliveregex.com/

    As this thread is huge already .. unless its about the regex, please open a new one. Appreciate it .

    Cheers
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.