Home › Forums › Calendar Products › Community Events › Issue with calling the_content() function
- This topic has 4 replies, 3 voices, and was last updated 9 years, 5 months ago by
Cliff.
-
AuthorPosts
-
November 9, 2016 at 10:16 am #1189792
Jeff
Participanthttp://scrippscollege.staging.wpengine.com/events/calendar/community/add
I have a function that calls the WordPress the_content() function, to populate my menu. It works fine on my all of my pages, except on the community event form page.
When I call the the_content() function, it adds the community form to all my drop down menus.
Here is my function
function menu_system($menu) {
if(!$menu) {
$menu = ‘9’ ; // Defaults Menu selection to About if none provided
}global $wpdb; // Taps into the global WordPress variables
$wpdb_backup = $wpdb; // Copies the global WordPress variables for laterglobal $switched;
switch_to_blog(1); // Switches over to the blog requested
global $post;$args = array(
‘page_id’ => $menu, // Grabs the menu page we’re looking for
);$output = ”; // Initialize the variable we’re going to use to hold our output
$menu_system = new WP_Query( $args ); // Select page we’re going to useif ( $menu_system->have_posts() ) {
while ( $menu_system->have_posts() ) {
$menu_system->the_post();$output = the_content();
}
}wp_reset_postdata(); // Resets the WP_Query
restore_current_blog(); // Restores the switch_to_blog() function$wpdb = $wpdb_backup; // Restores the global WordPress variables
return $output; // Return our output to the page: Scripps College menus.
}
November 9, 2016 at 1:08 pm #1189922Cliff
MemberHi Jeff.
I’m not sure how I can help with your customization (which we cannot provide such in-depth help for, per our Scope of Support / Terms), but I can give you a few details about the Community Events form “page”… It’s not a page or a single custom post type or even an archive.
It’s created via WP Router, which you can read a bit about at http://ben.lobaugh.net/blog/35542/wordpress-creating-new-routes-custom-urls-with-wp-router
If you need some coding help, you may want to ask your developer or reference our documentation and list of known customizers.
November 10, 2016 at 9:16 am #1190446Jeff
ParticipantI did a work around by installing ACF plugin and creating a custom field called “sub menu”. I then copy the content from the default description field into the new ACF field.
November 10, 2016 at 11:47 am #1190519Cliff
MemberI’m glad you got this sorted out. Thanks for letting me and others know about your workaround.
-
AuthorPosts
- The topic ‘Issue with calling the_content() function’ is closed to new replies.
