snorton

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 96 total)
  • Author
    Posts
  • in reply to: Switch hostname #1348045
    snorton
    Participant

    Hi, @luke-brownnepa-com,

    You can view your licenses here – (https://theeventscalendar.com/license-keys/)

    From that page, select Disconnect Now next to the Site URL you wish to remove. If you go back to your website and add your license again it should connect to the correct URL. I’ve had a similar problem before. Hope that helps. Cheers!

    in reply to: Set Default Featured Image if Not Specified Manually #1347933
    snorton
    Participant

    I’ve resolved my inquiry by using the category slug instead of its ID. I am intrigued why that works, but since it’s working I will leave it alone.

    For anyone else who wants to set a thumbnail (aka featured image) for a specific event category when it hasn’t been manually set, here’s the solution. Add the function below to your functions.php. Again, I didn’t want to simply display a substitute image in the single-post.php template, I wanted to actually set the image programmatically so that it can be called throughout the entire site. This single function can be expanded with additional elseif statements to conditionally apply to other post types or event categories.

    // Featured Image for Certain Event Categories
    function my_default_featured_images() {
    	global $post;
    	$featured_image_exists = has_post_thumbnail($post->ID);
    	if (!$featured_image_exists)  {
    		$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
    
    	if ($attached_image) {
    		foreach ($attached_image as $attachment_id => $attachment) {
    			set_post_thumbnail($post->ID, $attachment);
    			}
    		}
    // Identify the category this should apply to.
    	else if ( tribe_is_event( $post->ID ) ) {
    		if ( tribe_event_in_category( '[INSERT CATEGORY SLUG HERE]' ) ) {
    			set_post_thumbnail( $post->ID, '0000' ); // Change '0000' to the ID of whatever image you want as a default
    			wp_reset_postdata();
    				}
    			}
    		}
    	}
    add_action('the_post', 'my_default_featured_images');
    in reply to: Set Default Featured Image if Not Specified Manually #1347825
    snorton
    Participant

    Okay, because I know it works for regular post types, I’ve added a condition into that function:

    // Featured Image for Certain Post Categories
    function default_my_custom_featured_images() {
    	global $post;
    	$featured_image_exists = has_post_thumbnail($post->ID);
    	if (!$featured_image_exists)  {
    		$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
    
    	if ($attached_image) {
    		foreach ($attached_image as $attachment_id => $attachment) {
    			set_post_thumbnail($post->ID, $attachment);
    			}
    		}
    // Is this a job posting?
    	else if ( in_category( '19' ) ) {
    		set_post_thumbnail( $post->ID, '1504' );
    		wp_reset_postdata();
    			}
    // Is this a board meeting?
    	else if ( tribe_is_event( $post->ID ) ) {
    			set_post_thumbnail( $post->ID, '1740' );
    			wp_reset_postdata();
    			}
    		}
    	}
    add_action('the_post', 'default_my_custom_featured_images');

    This works! Great! But I want it to *only* work if it is in a specific category, so when I add that condition. Now there’s no result.

    // Is this a board meeting?
    	else if ( tribe_is_event( $post->ID ) && tribe_event_in_category( '21' ) ) {
    			set_post_thumbnail( $post->ID, '1740' );
    			wp_reset_postdata();
    			}
    

    I even tried just nesting the condition:

    
    // Is this a board meeting?
    	else if ( tribe_is_event( $post->ID ) ) {
    		if ( tribe_event_in_category( '21' ) ) {
    			set_post_thumbnail( $post->ID, '1740' );
    			wp_reset_postdata();
    				}
    			}
    
    in reply to: Set Default Featured Image if Not Specified Manually #1347751
    snorton
    Participant

    Hi Victor,

    Thank you for responding. Unfortunately that makes no difference. As mentioned, this function works just fine for regular post_types but isn’t for tribe_events. I modified the code a bit to first check if the post is a tribe_event, but still no luck. I’d rather not add another plugin to use as it doesn’t seem to be efficient for me for this specific scenario.

    function default_cat21_featured_image() {
    	global $post;
    	$event_id = $post->ID;
    		if( tribe_is_event( $event_id ) ) {
    			$featured_image_exists = has_post_thumbnail( $event_id );
    			if(tribe_event_in_category( '21' ) ) {
    				if ( !$featured_image_exists )  {
    					$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
    			
    				if ( $attached_image ) {
    					foreach ( $attached_image as $attachment_id => $attachment ) {
    						set_post_thumbnail( $event_id, $attachment );
    						}
    					}
    				else set_post_thumbnail( $event_id, '1740' );
    					wp_reset_postdata();
    				}
    			}
    		}
                            
    	}
    add_action( 'the_post', 'default_cat21_featured_image' );
    in reply to: Tribe shortcode can I add 2 categories? #1346743
    snorton
    Participant

    @courtney, for multiple categories he’s gotta use ‘categories’ and not ‘category’. (Sorry, I know this isn’t my thread, but I’ve just been hanging out around here – respectfully, of course – and thought I’d help some other folks while I wait for some feedback on one I posted).

    I posted above a solution but he indicated that wasn’t his desired effect. I think I got confused/mixed-up in the subsequent responses. Cheers 🙂

    in reply to: PHP – If Event Has Featured Image #1346304
    snorton
    Participant

    If you’ve followed the steps for overriding the template for single-events.php then all you have to do in this case is replace the line that calls the featured image in the PHP file with the following:

    if(has_post_thumbnail($event_id)) {
      echo '<div>' . tribe_event_featured_image( $event_id, ‘full’, false ) . '</div>'; 
    }

    The same principle applies to any instance on other template override pages where the post_thumbnail is called.

    You could even write a filter in your functions.php file that changes the html surrounding the image source:

    function custom_event_featured_image_html( $featured_image, $post_id, $size ) {
    	$link = true;
    	$image_html = get_the_post_thumbnail( $post_id, apply_filters( 'tribe_event_featured_image_size', $size, $post_id ) );
    	if ( ! empty( $image_html ) && apply_filters( 'tribe_event_featured_image_link', $link ) ) {
    		$featured_image .= '<div><a href="' . esc_url( tribe_get_event_link() ) . '">' . $image_html . '</a></div>';
    	}
    	elseif ( ! empty( $image_html ) ) {
    		$featured_image .= '<div>' . $image_html . '</div>';
    	}
    };
    add_filter( 'tribe_event_featured_image', 'custom_event_featured_image_html', 10, 3 );

    Modify as needed 🙂

    Cheers.

    in reply to: Tribe shortcode can I add 2 categories? #1346222
    snorton
    Participant

    That seems simple enough – the result of the shortcode displays the full calendar and there isn’t a way that I know of on the front end to filter the main calendar with more than one category (I’m just an average user like you). I’d suggest you submit that as a feature request! https://tribe.uservoice.com/forums/195723-feature-ideas

    in reply to: Tribe shortcode can I add 2 categories? #1346189
    snorton
    Participant

    Hey @gabaptist, I’m not sure, but in this thread it looks like you’re using quote marks instead of " quote marks. There is a difference between the two and, unfortunately, the use of the curly quote marks breaks PHP, so it also breaks shortcode functionality – that is the reason why the shortcode itself works but the arguments don’t.

    As far as your question regarding the shortcode example I provided, that came straight from the ECP knowledgebase – I presume it’s current since it functions properly. the [tribe_events_list] also operates as desired for me as designed when I use the straight quotes [tribe_events view="list" categories="am,pe" limit="4" tribe-bar="false"]

    Try that one and you should be good to go.

    • This reply was modified 6 years, 8 months ago by snorton. Reason: Responding to question about the shortcode example I provided
    in reply to: Tribe shortcode can I add 2 categories? #1346002
    snorton
    Participant

    Hey @gabaptist, as shown in this post, you can add multiple categories by separating them with commas.

    [tribe_events view="list" categories="am,pm,gm,cm" tribe-bar="false"]

    You can even just use the IDs for your event categories instead of the category name, like this:

    [tribe_events view="list" categories="#1,#2,#3" tribe-bar="false"]

    Peace!

    in reply to: Plugin Conflict with Pods Custom Post Type #1146807
    snorton
    Participant

    Ah – that makes sense. I temporarily commented out line 292 of ../plugins/pods/classes/PodsInit.php where handlebars.js is registered and it resolved the problem.

    I’ll report back to the Pods team – I certainly appreciate your time in looking at this issue.

    in reply to: Plugin Conflict with Pods Custom Post Type #1146280
    snorton
    Participant

    I downloaded and installed fresh copies of WordPress (4.5.3), The Events Calendar (4.2.3) and Events Calendar Pro (4.2.3) – along with a fresh copy of Pods (2.6.6) – in a local test environment. There were no conflicts with the three plugins activated and recurring event functionality behaved as expected (fully-functional, no issues). However, when creating a pod which extends the tribe_events Post Type the conflict occurs again:

    Console Error:

    handlebars.js:194 Uncaught Error: Parse error on line 110:
    ...tribe_checked_if_is 'yes' custom.day.[sa
    -----------------------^
    Expecting 'CLOSE', 'STRING', 'INTEGER', 'BOOLEAN', 'ID', 'SEP', got 'undefined'

    Specifically, I created a Pod to add a file upload for the event. In my use, The Events Calendar is used mostly for meetings so I wanted my users to upload their meeting agendas as PDFs using a dedicated media upload button which then displays a link to the file for download on the front end.

    ** I think I discovered the conflict is closely related to the File / Image / Video upload option as I added other types of fields (plain text, paragraph, relationships with other Post Types) and each time had no problem until I added the file upload. **

    in reply to: template tags in tabs? #121528
    snorton
    Participant

    No worries. I can’t say with 100% certainty that this will work without actually seeing the theme files, but in my above code, replace
    the_content()
    with
    wpautop(the_content(),true)

    Refer to the WordPress Codex for the wpautop function

    in reply to: template tags in tabs? #121428
    snorton
    Participant

    Try wrapping your content in the wpautop() function. It’s possible that your theme has removed the wpautop with a filter.

    in reply to: template tags in tabs? #121255
    snorton
    Participant

    Sorry @henkle, while I can understand why you wouldn’t want to publish a link, I cannot view what you’ve marked as private. That’s a feature available only to the Tribe folks.

    in reply to: template tags in tabs? #121244
    snorton
    Participant

    Care to share a link? I’ll take a quick look and see if there’s anything obvious that may be causing that.

Viewing 15 posts - 1 through 15 (of 96 total)