-1

I'm new to WP and looking to put a Call To Action (CTA) to my main menu. Currently the ordinary items are left aligned, and the CTA would be right aligned. So far this is what I've thought:

  • Hardcode it into the theme with the link to the page. Easy but ugly and error prone + the editor/author can't edit the link.
  • Define a secondary menu and just get first item (wp_get_nav_menu_items?). Better but seems odd to use a menu just to get an element.

Any other idea? Is there a prefered way of doing this? I'm inclined for the second option but just wanted to know if there are more ways.


Edit: originally posted on StackOverflow, Oliver's answer added down here. I repost the question because I think it better belongs here + I want more feedback.

6
  • 2
    CTA ? Computed tomography angiography ? Central Tibetan Administration ?
    – mmm
    Commented Mar 27, 2016 at 21:16
  • CTA is Call To Action i suppose. Commented Mar 27, 2016 at 21:55
  • 1
    @doup you have already ask this in stackoverflow and you have there the good answer of Oliver White: You have to use the last item of your menu and set a custom class to it. Then you will assign the necessary css rules to this class in main css file of your theme (or better child-theme) for example float:right; Commented Mar 27, 2016 at 22:08
  • Updated original question. So, @Louis you also think that's the good answer? The user must be aware of the convention and remember to add the class? Feel free to add answers so that they can be voted & accepted.
    – doup
    Commented Mar 28, 2016 at 17:39
  • You mean the Author/Editor user could delete this CTA menu item to replace it by a new one? In that case the user have to set the class in the new item menu. But if this user just edit this CTA menu item, there is no problem. Commented Mar 28, 2016 at 18:16

1 Answer 1

0

As posted in StackOverflow by Oliver White:

You can add this item as last in your menu, then assign custom class to this item and add required styles (positioning, CTA styles).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.