• Resolved oktafish

    (@oktafish)


    Hey, thanks for a great plugin.
    I have one question though.
    How would you go about styling individual “item-menu-title” ?
    Not globally, so that individual items within the section can be styled differently.
    So say, grilled steak title can have a different style than a fried one.
    I cant provide a link as Im developing locally.
    I hope the question is clear enough ??

    https://www.ads-software.com/plugins/food-and-drink-menu/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi oktafish,

    You’ll need to ensure that each menu item has an ID or class that is unique to them if you want to target individual menu items.

    The best way to do this is to create a custom menu template. Once you’ve got a handle on the steps suggested in that tutorial, I’d recommend you copy the Menu Item template into your theme or custom plugin and modify Line 8:

    <li<?php echo fdm_format_classes( $this->classes ); ?>>

    Add the menu item id to the array of classes:

    <li<?php echo fdm_format_classes( array_push( $this->classes, 'fdm-item-' . $this->id ) ); ?>>

    That should produce a class like fdm-item-1, or whatever the ID number is, which you can then use to target for specific styles.

    Thread Starter oktafish

    (@oktafish)

    Thank you for your super fast reply. Ive overridden the templates and made the changes, unfortunately that hasnt worked. The html isn`t showing a unique id or class. However it did change the generated mark up.
    Here is the original code snippet :

    <li class="fdm-item fdm-item-has-price">
    
    		<div class="fdm-item-panel">
    
    			<p class="fdm-item-title">Prawns pil pil</p><div class="fdm-item-price-wrapper">
    	<span class="fdm-item-price">7 €</span>
    </div><div class="fdm-item-content">
    	<p>Spicy prawns in butter and oil with garlic and chilli served with bread</p>
    </div>
    			<div class="clearfix"></div>
    		</div>
    
    		</li>

    and here is the amended version:

    <li class="">
    
    		<div class="fdm-item-panel">
    
    			<p class="fdm-item-title">Prawns pil pil</p><div class="fdm-item-price-wrapper">
    	<span class="fdm-item-price">7 €</span>
    </div><div class="fdm-item-content">
    	<p>Spicy prawns in butter and oil with garlic and chilli served with bread</p>
    </div>
    			<div class="clearfix"></div>
    		</div>
    
    		</li>

    as you can see, the changes seemed to loose the class “fdm-item fdm-item-has-price” other than that no change.

    Hi oktafish,

    That’s my mistake. Instead of this line:

    <li<?php echo fdm_format_classes( array_push( $this->classes, 'fdm-item-' . $this->id ) ); ?>>

    Try this:

    <?php array_push( $this->classes, 'fdm-item-' . $this->id ); ?>
    <li<?php echo fdm_format_classes( $this->classes ); ?>>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Styling Item Title’ is closed to new replies.