• Resolved purplearth

    (@purplearth)


    I’m helping a client set up a site that uses Event Manager. We set up the default page template to show the content of an info page in the sidebar. In sidebar.php, we’re using code that looks something like this…

    <?php
    $vp_info_id = 00; // replace 00 with actual info page id
    $vp_info_post = get_post($vp_info_id);
    $vp_content = $vp_info_post->post_content;
    $vp_content = apply_filters(‘the_content’, $vp_content);
    $vp_content = str_replace(‘]]>’, ‘]]>’, $vp_content);
    echo $vp_content;
    ?>

    This works as intended site-wide, with the content of the info page showing in the sidebar…

    …except on the designated events page. The content area of the events page has the list of events (with the search stuff on the top, etc.), but the exact same content is now showing up in the sidebar instead of the info page content.

    Is there a template we have to tweak someplace? What do we have to do to get the info content in the sidebar instead of the events page content?

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 8 replies - 1 through 8 (of 8 total)
  • can you provide a sample link or screenshots?

    Thread Starter purplearth

    (@purplearth)

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    Why not use widgets? Also, the_content filter may be doing this.

    Thread Starter purplearth

    (@purplearth)

    The idea was to have the info text in a place that the client could easily edit it from time to time. I think having it in a widget (instead of a post) would introduce a couple more hoops to jump thru (text widget would mean editing html tags and such), and I’m hesitant to add another plugin to accomplish something that can be accomplished with a few lines of template code.

    I was afraid that this was an issue introduced by the way EM overrides a page’s content. I can explore other workarounds, and I’m open to other suggestions.

    Thread Starter purplearth

    (@purplearth)

    OK, I’m exploring the Query Posts plugin (https://www.ads-software.com/extend/plugins/query-posts/). Its widget contains a custom loop ($new_query = new WP_Query( $args );), and the content is displayed by a call to the_content().

    So now my question is, will this solve my problem, or will the hook you use clobber the content in the widget?

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    looking again, chances are it’s because you’re not in a WP loop or you’re doing this within a WP loop. the_content filter would work actually, but you need to know how those work to make this sort of thing happen.

    codex.www.ads-software.com/Class_Reference/WP_Query – good starting point

    mind you, if you register a sidebar and use a combination of plugins, you can probably do this with little to no coding.

    Thread Starter purplearth

    (@purplearth)

    So are you suggesting that if I grab and filter the content from inside a loop (I don’t right now), it would work as intended?

    Thread Starter purplearth

    (@purplearth)

    Fixed it.

    I replaced the code above with the following…

    $vp_sidebar_query = new WP_Query( ‘page_id=61’ );
    if ( $vp_sidebar_query->have_posts() ) {
    while ( $vp_sidebar_query->have_posts() ) {
    $vp_sidebar_query->the_post();
    the_content();
    }
    }

    So yeah, wrapping a loop around the fetching of the content, rather than fetching the content explicitly outside of a loop, did the trick.

    Thanks for nudging me in the right direction.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Events Manager] Sidebar content overridden’ is closed to new replies.