• 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);
    e.g.
    createWidgetLogic(“Calendar”, “(get_post_type()==’event’)”);
    so that the Calendar Widget is only displayed with event posts.

    Thank you!

    http://wordpress.org/extend/plugins/widget-logic/

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    Thread Starter stef1979

    (@stef1979)

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

    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…

    $wl_options=get_option('widget_logic');
    …[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.

    Thread Starter stef1979

    (@stef1979)

    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!

    Thread Starter stef1979

    (@stef1979)

    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.