• Resolved bloug

    (@bloug)


    Hi. I try to integrate the galley in my function php file. I think my syntax is wrong.

    I tried on line 2

    array_push($post_types, array('gd_place','gd_bands'));

    and

    array_push($post_types, 'gd_place','gd_bands');

    I get these errors:

    Warning: Missing argument 1 for add_featured_galleries_to_ctp(), called in /home2/ultraman/public_html/walago.co/go/wp-content/themes/Divi-child/functions.php on line 145 and defined in /home2/ultraman/public_html/walago.co/go/wp-content/themes/Divi-child/functions.php on line 221

    Warning: array_push() expects parameter 1 to be array, null given in /home2/ultraman/public_html/walago.co/go/wp-content/themes/Divi-child/functions.php on line 222

    line 222 is line 2.
    line 145 is where I insert the function
    add_featured_galleries_to_ctp();

    I’d appreciate any help.

    Thanks

    https://wordpress.org/plugins/featured-galleries/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Andy Mercer

    (@kelderic)

    I’ll test it out this evening.

    Thread Starter bloug

    (@bloug)

    Great! Thanks

    Plugin Author Andy Mercer

    (@kelderic)

    Could you copy and past here the entire function in question? From the error it sounds like the $post_types variable isn’t properly coming in.

    Thread Starter bloug

    (@bloug)

    Sure. I don’t know if the proper way to do it but here’s the whole file.

    The function is called at line 145 which is usually a function for another gallery used (geodirectory)

    Other geodirectory funtions are below that

    I’ve inserted the featured gallery function at line 221

    ———————

    <?php
    
    require_once 'include/cpt-options.php';
    require_once 'include/Tax-meta-class/Tax-meta-class.php';
    
    include 'include/my_shortcodes.php';
    
    add_filter('geodir_breadcrumb','geodir_breadcrumb_remove',10,2);
    	function geodir_breadcrumb_remove($breadcrumb, $separator){
    	return '';
    	}
    
    	/**
    	 * Add image size
    	 */
    add_image_size( 'geo-gallery-custom', 320, 200 );
    
    /**
     * enqueue the scripts
     */
    function geo_divi_scripts() {
    	wp_enqueue_script( 'masonry-js', get_stylesheet_directory_uri() . '/js/masonry.pkgd.min.js', array('jquery'), '1.0.0', true );
    	wp_enqueue_script( 'child-js', get_stylesheet_directory_uri() . '/js/script.js', array('jquery'), '1.0.0', true );
    }
    
    add_action( 'wp_enqueue_scripts', 'geo_divi_scripts' );
    
    // left categories on gd
    add_action('geodir_listings_sidebar_left_inside', 'left_gd_sidebar');
    function left_gd_sidebar() {
    	// echo "done";
    }
    
    // remove the select view dropdown
    remove_action('geodir_before_listing', 'geodir_list_view_select', 100);
    remove_action('geodir_listings_page_title', 'geodir_action_listings_title', 10);
    
    // add metabox to custom taxonomies
    if (is_admin()){
    	$prefix = 'dgeo_';
    	$config = array(
    		'id' => 'dgeo_tax_meta_box',          // meta box id, unique per meta box
    		'title' => 'Color',          // meta box title
    		'pages' => array('gd_placecategory', 'gd_blogscategory', 'gd_bandscategory', 'gd_online_placescategory' ),       // taxonomy name, accept categories, post_tag and custom taxonomies
    		'context' => 'normal',            // where the meta box appear: normal (default), advanced, side; optional
    		'fields' => array(),            // list of meta fields (can be added by field arrays)
    		'local_images' => false,          // Use local or hosted images (meta box images for add/remove)
    		'use_with_theme' => true          //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
    	  );
    	$dgeo_meta =  new Tax_Meta_Class($config);
    	$dgeo_meta->addColor($prefix.'cat_color',array('name'=> __('Color ','tax-meta')));
    	$dgeo_meta->Finish();
    }
    
    // single detail page
    remove_action('geodir_detail_before_main_content', 'geodir_breadcrumb', 20);
    remove_action('geodir_detail_before_main_content', 'geodir_action_geodir_sidebar_detail_top', 10);
    add_action ('geodir_detail_before_main_content', 'geo_single_wide_top', 10);
    
    remove_action('geodir_details_main_content', 'geodir_action_page_title', 20);
    remove_action('geodir_details_main_content', 'geodir_action_details_slider', 30);
    remove_action('geodir_details_main_content', 'geodir_action_details_taxonomies', 40);
    remove_action('geodir_details_main_content', 'geodir_action_details_next_prev', 80);
    remove_action('geodir_details_main_content', 'geodir_show_detail_page_tabs', 60);
    add_action('geodir_details_main_content', 'geo_tab_content', 60);
    
    // single details sidebar
    remove_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_place_details', 10);
    remove_action('geodir_detail_sidebar_inside', 'geodir_details_sidebar_widget_area', 20);
    add_action('geodir_detail_sidebar_inside', 'geo_details_sidebar', 10);
    
    function geo_single_wide_top() {
    	global $post;
    	$thumb_id = get_post_thumbnail_id();
    	$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
    	if ( isset($thumb_url_array[0]) ) {
    		$thumb_url = 'style="background-image: url(' .$thumb_url_array[0].');"';
    
    	} else {
    		$thumb_url = '';
    	}
    
    	// $post_details = geodir_get_post_info($post->ID);
    
    	ob_start();
    	// print_r( $post_details );
    	?>
    	<div class="single-header-image cleearfix" <?php echo $thumb_url; ?>>
    		<div class="single-header-content">
    			<h1><?php the_title(); ?></h1>
    			<div><?php echo geodir_get_post_meta($post->ID,'geodir_geo_description',true); ?></div>
    		</div>
    		<div class="dir-tab-menu"><?php geo_tab_menu(); ?></div>
    	</div>
    	<?php
    	echo ob_get_clean();
    }
    
    function geo_tab_menu() {
    	global $post;
    	$vars = array(
    		'geodir_geo_products' => 'products',
    		'geodir_geo_services' => 'services',
    		'geodir_geo_specials' => 'specials',
    		'geodir_sitemap'  => 'sitemap'
    		);
    		?>
    		<span class="active" href="#profile">Profile</span>
    		<span href="#map">Map</span>
    		<?php
    	foreach ($vars as $var => $id) {
    		if ( geodir_get_post_meta( $post->ID, $var, true ) ) :
    		?>
    		<span href="#<?php echo $id ?>"><?php echo $id; ?></span>
    		<?php
    		endif;
    	}
    }
    
    function geo_tab_content() {
    	global $post;
    	$vars = array(
    		'geodir_geo_products' => 'products',
    		'geodir_geo_services' => 'services',
    		'geodir_geo_specials' => 'specials',
    		'geodir_sitemap' => 'sitemap',
    		'geodir_post_latitude' => 'map'
    		);
    		?>
    		<div id="profile" class="dir-tab-content active"><?php the_content(); ?></div>
    		<div id="map" class="dir-tab-content"><?php geo_map_display(); ?></div>
    
    		<?php
    	foreach ($vars as $var => $id) {
    		if ( $temp = geodir_get_post_meta( $post->ID, $var, true ) ) :
    		?>
    		<div id="<?php echo $id ?>" class="dir-tab-content"><?php echo $temp; ?></div>
    		<?php
    		endif;
    	}
    	geo_details_video();
    	add_featured_galleries_to_ctp();
    
    }
    
    function geo_map_display() {
    	global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields;
    
    	$map_args = array();
        $map_args['map_canvas_name'] = 'detail_page_map_canvas';
        $map_args['width'] = '600';
        $map_args['height'] = '300';
        if ($post->post_mapzoom) {
            $map_args['zoom'] = '' . $post->post_mapzoom . '';
        }
        $map_args['autozoom'] = false;
        $map_args['child_collapse'] = '0';
        $map_args['enable_cat_filters'] = false;
        $map_args['enable_text_search'] = false;
        $map_args['enable_post_type_filters'] = false;
        $map_args['enable_location_filters'] = false;
        $map_args['enable_jason_on_load'] = true;
        $map_args['enable_map_direction'] = true;
        $map_args['map_class_name'] = 'geodir-map-detail-page';
        geodir_draw_map($map_args);
    }
    
    function geo_details_sidebar() {
    	global $post;
    	?>
    
    			<h3><?php the_title(); ?></h3>
    
    			<div class="sidebar-address sidebar-item clearfix">
    				<i class="fa fa-globe"></i>
    				<?php echo $post->post_address; ?>,
    				<?php echo $post->post_city . ' ' . $post->post_state . ' ' . $post->post_zip; ?>
    			</div>
    
    			<?php if ( $temp = geodir_get_post_meta( $post->ID, 'geodir_contact', true ) ) : ?>
    				<div class="sidebar-phone sidebar-item clearfix">
    					<i class="fa fa-mobile"></i>
    					<a href="tel:<?php echo $temp; ?>"><?php echo $temp; ?></a>
    				</div>
    			<?php endif; ?>
    
    			<?php if ( $temp = geodir_get_post_meta( $post->ID, 'geodir_email', true ) ) : ?>
    				<div class="sidebar-email sidebar-item clearfix">
    					<i class="fa fa-envelope-o"></i>
    					<a href="mailto:<?php echo $temp; ?>"><?php echo $temp; ?></a>
    				</div>
    			<?php endif; ?>
    
    			<?php if ( $temp = geodir_get_post_meta( $post->ID, 'geodir_timing', true ) ) : ?>
    				<div class="sidebar-time sidebar-item clearfix">
    					<i class="fa fa-clock-o"></i>
    					<?php echo $temp; ?>
    				</div>
    			<?php endif; ?>
    
    			<?php if ( $temp = geodir_get_post_meta( $post->ID, 'geodir_website', true ) ) : ?>
    				<div class="sidebar-website sidebar-item clearfix">
    					<i class="fa fa-external-link"></i>
    					<a target="_blank" href="<?php echo $temp; ?>"><?php echo str_replace(array('www.', 'http://', 'https://'), '', $temp); ?></a>
    				</div>
    			<?php endif; ?>
    
    			<?php get_card_social($post->ID); ?>
    
    	<?php
    }
    
    function add_featured_galleries_to_ctp( $post_types ) {
        array_push($post_types, array('gd_place','gd_bands')); // ($post_types comes in as array('post','page'). If you don't want FGs on those, you can just return a custom array instead of adding to it. )
        return $post_types;
    }
    add_filter('fg_post_types', 'add_featured_galleries_to_ctp' );
    
    function geo_details_gallery() {
    	global $post;
    	$post_images = geodir_get_images($post->ID, 'full', get_option('geodir_listing_no_img'));
    	$thumbnail_id = get_post_thumbnail_id( $post->id );
    	if (!empty($post_images)) {
    		echo '<div class="geo-gallery">';
            foreach ($post_images as $image) {
                // echo $image->src;
                if ( $image->id != $thumbnail_id ) :
                ?>
            	<a href="<?php echo $image->src; ?>" rel="lightbox">
            		<img src="<?php echo $image->src; ?>">
            	</a>
                <?php
                endif;
            }
            echo '</div>';
        }// endfore
    }
    
    function geo_details_video() {
    	global $post;
    	// $video =
    	echo '<div class="details-embed-video">'. wp_oembed_get( geodir_get_video( $post->ID ) ) . '</div>';
    }
    
    //random
    
    add_action('init','fivera_explore_button');
    function fivera_explore_button() {
           global $wp;
           $wp->add_query_var('random');
           add_rewrite_rule('random/?$', 'index.php?random=1', 'top');
    }
    
    add_action('template_redirect','random_template');
    function random_template() {
           if (get_query_var('random') == 1) {
    
    			   $posts = get_posts(array(
    	'post_type' => array('gd_place', 'gd_online_places'),
    	'orderby' => 'rand',
    	'numberposts' => '1'
    ));
                   foreach($posts as $post) {
                           $link = get_permalink($post);
                   }
                   wp_redirect($link,307);
                   exit;
           }
    }

    Plugin Author Andy Mercer

    (@kelderic)

    Right now you have:

    function add_featured_galleries_to_ctp( $post_types ) {
        array_push($post_types, array('gd_place','gd_bands'));
        return $post_types;
    }
    add_filter('fg_post_types', 'add_featured_galleries_to_ctp' );

    Try switching the push line to this:

    array_push( $post_types, 'gd_place', 'gd_bands' );

    Based on this:

    http://php.net/manual/en/function.array-push.php

    Let me know if that fixes it. If not, we need to look at what $post_types is starting as. So we’ll want to do an array dump and print it out.

    Thread Starter bloug

    (@bloug)

    Hi and thanks for your response. I’ve already tried that but I’ve just tried it again just in case and I got the same result.

    I must admit my php knowledge is pretty limited. I don’t know how to do an array dump.

    Plugin Author Andy Mercer

    (@kelderic)

    I hate this board. My comment just got swallowed. Short answer is:

    var_dump( $post_types )

    Put it in the add_featured_galleries_to_ctp function. It’ll print information out near the top of the page (use view page source to find it)

    Plugin Author Andy Mercer

    (@kelderic)

    Hey, it’s been a couple days. Have you had a change yet to try out the var_dump?

    Plugin Author Andy Mercer

    (@kelderic)

    Since I haven’t heard back from you, I’m assuming that you figured out the issue, and I’m marking this as resolved.

    Thread Starter bloug

    (@bloug)

    I’ve been very busy. I’ll give it a shot later today.

    Thread Starter bloug

    (@bloug)

    Hi. Thanks to still be here.I’ve added it to the function like this:

    function add_featured_galleries_to_ctp( $post_types ) {
        array_push($post_types, 'gd_place','gd_online_places'); // ($post_types comes in as array('post','page'). If you don't want FGs on those, you can just return a custom array instead of adding to it. )
        return $post_types;
    	var_dump( $post_types );
    }
    add_filter('fg_post_types', 'add_featured_galleries_to_ctp' );

    You can see the source here but since I don’t know what to look for, I’ve not find anything valuable.

    http://www.walago.co/go/places/united-states/illinois/chicago/barber-shops/joes-barber-shop/

    Plugin Author Andy Mercer

    (@kelderic)

    Anything after a “return” line doesn’t run, because return finishes up any function that it’s inside of.

    Put the var_dump before the return. Also, write echo 'THIS IS BEFORE VAR DUMP'; before the var_dump line. Then in the page source, you can look for that text, and what follows is the var_dump.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Function.php array syntax’ is closed to new replies.