Support » Plugin: Widget Logic » Invoke Widget Logic Programatically

  • Hi

    Is there any way, I could invoke the configuration of the placement of a widget for a specific posttype programatically?
    I would like to do something like
    createWidgetLogic(WIDGETNAME, WIDGETLOGIC);
    createWidgetLogic(“Calendar”, “(get_post_type()==’event’)”);
    so that the Calendar Widget is only displayed with event posts.

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor alanft


    If get_post_type()==’event’ is the logic you need (and it looks good to me), put it in the calendar widget’s widget logic text field and see what you get

    the logic is ok, I tested it. What I would like to do, is to define that logica from within another plug-in, programatically!

    Plugin Contributor alanft


    ah, i get you. ok so the main params for widget logic can be retrieved from the ‘widget_logic’ option, manipulated and then updated like this…

    …[do stuff to the wl_options hash]…
    update_option('widget_logic', $wl_options);

    The keys of the hash are the widget IDs, the values are the widget logic text. Take care that you control the widget logic text – as it will get EVAL’d.

    Thanks for your help. That;s exatcly what I needed.
    I am, however, struggling with the structure of the option value. could you give me a standard example of how you would create a new entry in wl_options?

    Thanks you so much!

    I figured it out! Thanks a lot for your support!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Invoke Widget Logic Programatically’ is closed to new replies.