Skip Navigation

[Resolved] Manually adding item to a view

This support ticket is created 2 years, 4 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: Asia/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by johnh-18 2 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#2235609

Tell us what you are trying to do?
I am trying to manually add a linked first item to the following 'view' using [wpv-item index=1] but it breaks the view

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<ul class="wpv-loop js-wpv-loop">
<wpv-loop>

  • [wpv-post-body view_template="loop-item-in-beauty-wellbeing-categories"]
  • </wpv-loop>

    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
    [wpml-string context="wpv-views"]No items found[/wpml-string]
    [/wpv-no-items-found]
    [wpv-layout-end]

    What is the link to your site?
    hidden link

    The view above is for the category links below the headline and the link I am trying to add manually should look just like the category links

    Great if you can help.
    Best regards / john

    #2235885

    Waqar
    Supporter

    Languages: English (English )

    Timezone: Asia/Karachi (GMT+05:00)

    Hi John,

    Thank you for contacting us and I'd be happy to assist.

    It seems some part of the code was removed by the message editor.

    Can you please share temporary admin login details along with the page, where this view can be seen? Also, what will this manual link be linked to?

    Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

    regards,
    Waqar

    #2238199

    Waqar
    Supporter

    Languages: English (English )

    Timezone: Asia/Karachi (GMT+05:00)

    Thank you for sharing these details.

    For manually creating the first taxonomy term link from the view "beauty-wellbeing-categories", you'll need to divide the loop item's content into two main conditional blocks, based on the value of the "wpv-loop-index" shortcode:
    https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-loop-index

    
    [wpv-conditional if="[wpv-loop-index] eq 1"]
    Conditional block for first loop item
    [/wpv-conditional]
    
    [wpv-conditional if="[wpv-loop-index] ne 1"]
    Conditional block for other loop items
    [/wpv-conditional]
    
    

    Next, for the inner conditions for the first loop items, you'll need to update the evaluations so that the term ID 454 (Beauty & Wellbeing) is used, instead of the current term ID from the view's loop.

    Here is how the complete content in the loop item will look like:

    
    [wpv-conditional if="[wpv-loop-index] eq 1"]
        [wpv-conditional if="[is-tax term=454 tax='category'] eq 1"]
        <span class="magtxt-active"><a href="[wpv-taxonomy-url term_id='454']">All</a></span>
        [/wpv-conditional]
        [wpv-conditional if="[is-tax term=454 tax='category'] ne 1"]
        <span class="magtxt"><a href="[wpv-taxonomy-url term_id='454']">All</a></span>
        [/wpv-conditional]
    [/wpv-conditional]
    
    [wpv-conditional if="[wpv-loop-index] ne 1"]
        [wpv-conditional if="[is-tax term=[wpv-taxonomy-id] tax='category'] eq 1"]
        <span class="magtxt-active">[wpv-taxonomy-link]</span>
        [/wpv-conditional]
        [wpv-conditional if="[is-tax term=[wpv-taxonomy-id] tax='category'] ne 1"]
        <span class="magtxt">[wpv-taxonomy-link]</span>
        [/wpv-conditional]
    [/wpv-conditional]
    
    

    As for your other question, can you please share some examples of views that are being used for different CPTs, but for similar functionality? I'll be in a better position to guide you accordingly.

    #2238203

    Hi Waqar,
    Thanks you for your message. I will give this a go but may not be until late Tuesday evening - will keep you posted.
    Best regards / jan

    #2238689

    Waqar
    Supporter

    Languages: English (English )

    Timezone: Asia/Karachi (GMT+05:00)

    Thanks for the update and please take your time.

    #2238851

    Hi Waqar,
    I did not realise you had kindly already implemented the code for the 'beauty & wellbeing' CPT until I logged in yesterday evening - many thanks. I spent yesterday evening implementing the same solution for the other CPTs.
    I mentioned in an earlier message that the way I have created the view means that I have to have separate views for each CPT and you asked for an example - please see hidden link
    Also, if you go to hidden link you will see that 'VIEW ALL' is highlighted in red which is just as it should be. However, if you click on any of the destinations, eg hidden link you will see that the red highlight has disappeared. The reason, I believe, is that the links for 'beauty & wellness' or 'for your home' are child categories. However, for 'villas and chalets', the links are not regular category links but a separate taxonomy. The reason I had to do it this way is that hidden link hidden link hidden link can have the same destination, eg Spain exists for both 'villas & chalet' and 'luxury real estate' but I can only have Spain as a child-category once - hence separate taxonomies. Is there a way around that by tweaking the function I borrowed from https://toolset.com/forums/topic/setting-a-specific-style-for-the-active-taxonomy/?
    Again, please let me know if you prefer I open a separate ticket for the above.
    Thank you for your help and best regards / jan

    New threads created by Waqar and linked to this one are listed below:

    https://toolset.com/forums/topic/split-managing-conditional-display-for-multiple-taxonomies/

    #2239099

    Waqar
    Supporter

    Languages: English (English )

    Timezone: Asia/Karachi (GMT+05:00)

    I've created a separate ticket for your other question and will follow up on it shortly.
    ( ref: https://toolset.com/forums/topic/split-managing-conditional-display-for-multiple-taxonomies/ )

    You're welcome to mark this ticket as resolved and start a new one for each new question or concern.

    #2239903

    My issue is resolved now. Thank you!

    This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.