Skip Navigation

[Resolved] Need help with conditional

This support ticket is created 3 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by nicoleR-3 3 years, 2 months ago.

Assisted by: Jamal.

Author
Posts
#2172507
Screenshot 2021-09-17 at 20-02-01 My Dressage Connect Account - Dressage Connect.png

Tell us what you are trying to do?
I have an account area that I have set up with a section where members can update their posts. There are four different post types - trainer, breeder, stallion, and blog post. I have set up the "Edit this post" for each type and that is working fine. I just want to know what conditional statements I would select so that there would not be blank areas in the layout where the Edit Post link is hidden depending on the post type. You can see what I am trying to describe in the screenshot below. I would like all the Edit Post links at the same position on each card, with the "Delete" link directly underneath it, but I couldn't figure out what conditional options to choose.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2173123

Hello and thank you for contacting Toolset support.

If I understand well, you want to have the "Edit" and "Delete" links close to each other, at the bottom, or just after the title, without having blank space between them, right?
If yes, I must say that the styles are usually affected by the used theme, then by the settings on each block. I'll need to get access to your website to check the view closely. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2173885

Thank you for the credentials. I confirm they are working for me. However, I think, I'll need to create a post to check, right? If yes, please create a couple of posts and make me the authors so I can see them.

#2174487

Oh sorry, forgot about that. I set it so there is one post or each type. You should be able to see them now.

#2174999

You are currently using one Fields&Text block for the edit link of each of the 4 post types. So, depending on the type of the current post of the loop, the edit link will be in a different block. So, there will be empty blocks that will cause the blank space, because all blocks will have a <p> tag.
Check this screenshot

I suggest one of the following:
- Use only one Fields&Text block, and put all the edit links shortcodes inside of it. Inside of the same <p> tag.
- Wrap each Fields&Text block inside a conditional block that will check if it is the appropriate post type or not.
- Add the following Javascript to the view. This code will remove empty paragraphs that cause the blank space.

jQuery(function($){
    $('.tb-fields-and-text p').each(function(){
        var p = jQuery(this)
        if( !p.text() ) p.remove()
    })
})

Does this make sense? Let me know if you have any questions.

#2175595

The javascript snippet worked perfectly. My issue is resolved now. Thank you so much!