Fi Fi P
Forum Replies Created
-
Thanks for the feedback, I am still having a little trouble with my code.
Thank you for your patience but if I strip it back just to get it clear in my head. Below calls three events in category 78<div id=”container”>
<?php
echo do_shortcode(‘[events_list limit=”3″ category=78]<div class=”HM-event”>
<div class=”HM-pic”>#_EVENTIMAGE{300,0}</div>
<div class=”HM-eventnm”>#_EVENTLINK</div>
<div class=”HM-eventdt”>#_EVENTDATES</div>
<div class=”HM-venue”>
#_ATT{Venue}</div><div class=”tickets”>#_ATT{Tickets}</div>
</div>[/events_list]’);
?></div><!– #container –>
I now want to add an instruction: if there are no events in category 78, just show the next event coming up. Do I add an if instruction afterwards. The below gives me the dreaded white screen:
<div id=”container”>
<?php
echo do_shortcode(‘[events_list limit=”3″ category=78]<div class=”HM-event”>
<div class=”HM-pic”>#_EVENTIMAGE{300,0}</div>
<div class=”HM-eventnm”>#_EVENTLINK</div>
<div class=”HM-eventdt”>#_EVENTDATES</div>
<div class=”HM-venue”>
#_ATT{Venue}</div><div class=”tickets”>#_ATT{Tickets}</div>
</div>[/events_list]’);?>
$count = $EM_Events::count( array( ‘scope’ => ‘future’) );
<?php
if ($count > 0) {
echo do_shortcode(‘[events_list limit=”1″]<div class=”HM-event”>
<div class=”HM-pic”>#_EVENTIMAGE{300,0}</div>
<div class=”HM-eventnm”>#_EVENTLINK</div>
<div class=”HM-eventdt”>#_EVENTDATES</div>
<div class=”HM-venue”>
#_ATT{Venue}</div><div class=”tickets”>#_ATT{Tickets}</div>
</div>
[/events_list]’);?></div><!– #container –>
I know I am getting in a muddle with this one, your help is really appreciated!x
Thank You!
Thanks, so where would I put that?
I don’t quite understand, the current code shows ‘No Events’ so do I need to add another instruction? I tried it without ‘if’, saying show 3 events in category 78, ‘else’ show a single event but still not working:
<div id=”container” class=”js-masonry”data-masonry-options='{ “columnWidth”: 15, “itemSelector”: “.HM-event” }’>
<?php
echo do_shortcode(‘[events_list limit=”3″ category=78]<div class=”HM-event”>
<div class=”HM-pic”>#_EVENTIMAGE{300,0}</div>
<div class=”HM-eventnm”>#_EVENTLINK</div>
<div class=”HM-eventdt”>#_EVENTDATES</div>
<div class=”HM-venue”>
#_ATT{Venue}</div><div class=”tickets”>#_ATT{Tickets}</div>
</div>[/events_list]’);
} else { ?>
<?php
echo do_shortcode(‘[events_list limit=”1″]<div class=”HM-event”>
<div class=”HM-pic”>#_EVENTIMAGE{300,0}</div>
<div class=”HM-eventnm”>#_EVENTLINK</div>
<div class=”HM-eventdt”>#_EVENTDATES</div>
<div class=”HM-venue”>
#_ATT{Venue}</div><div class=”tickets”>#_ATT{Tickets}</div>
</div>[/events_list]’);?>
</div><!– #container –>
I basically want to show a list of events from a specific category unless there aren’t any in that category then just show the next event regardless of what category it is in.
In the php above I have called for it to show one event from category 6 in the Live Events block and the rest is styling divs. I wondered if it was an else instruction I needed as below but it doesn’t work:
<div id=”block2″><div id=”block2-title”>LIVE EVENTS</div>
<?php
if (‘[events_list limit=”1″ category=6]’)) { echo do_shortcode(‘[events_list limit=”1″ category=6]#_EVENTIMAGE{145,90} </br>
<div class=”postname”>#_EVENTLINK</div>
<div class=”e-date”>#_EVENTDATES</br>#_EVENTTIMES</div><div class=”postexcerpt”>#_EVENTEXCERPT{20,…}</div>
<div class=”more-link” style=”margin-left: 10px”>More</div>
<div class=”tickets” style=”margin-left: 10px”>
#_ATT{Tickets}</div>[/events_list]’);
} else do_shortcode(‘[events_list limit=”1″]#_EVENTIMAGE{145,90} </br>
<div class=”postname”>#_EVENTLINK</div>
<div class=”e-date”>#_EVENTDATES</br>#_EVENTTIMES</div><div class=”postexcerpt”>#_EVENTEXCERPT{20,…}</div>
<div class=”more-link” style=”margin-left: 10px”>More</div>
<div class=”tickets” style=”margin-left: 10px”>
#_ATT{Tickets}</div>[/events_list]’); ?>
</div>Forum: Hacks
In reply to: Featured imageI solved it in the end!
If anyone else has this same problem my solution is below:
Set Featured Image to a specific size
In functions.php
<?php
add_image_size( ‘artist’, 1000, 300, array( ‘left’, ‘top’ ) ); // Hard crop left top
Then in my page.php when I call for the feature image:
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail(‘artist’);
}
?>Don’t forget to regenerate your thumbnails!
Forum: Fixing WordPress
In reply to: Targeting a taxonomyIts the // do something bit I think I am getting wrong
<?php
if( has_term( ‘event’, ‘non-spektrix’ ) ) {
<style>.block-content #instancesBlock{display: none;} </style>
}
<?php endif; ?>The above isn’t working still for an event tagged as ‘non-spektrix’
I will want to do something similar with hiding a div when a certain page template is used but I am definately missing somehting here!Forum: Fixing WordPress
In reply to: Targeting a taxonomy<?php if( get_field(‘non_spektrix’) ): ?>
<style>.block-content #instancesBlock{display: none;} </style>
<?php endif; ?>Forum: Fixing WordPress
In reply to: Targeting a taxonomyI tried the code below, and nothing!
<?php if($post->ID == “696”){
<style> #instancesBlock {display: none;} </style>
<?php } ?>
Forum: Themes and Templates
In reply to: Weird… masonry gutterWidth stops working on 3.9 updateI just used this and it worked perfectly, thanks!
Forum: Everything else WordPress
In reply to: Alternating between two Home PagesI thought I had it with the above code, but it is still not working
Forum: Everything else WordPress
In reply to: Alternating between two Home Pages<?php
$hour = date(‘H’); // hour of the day, 24 hour clock
if( $hour >= 06 or $hour < 12)
if(is_front_page()) { ?>
<div>
<?php
$id=247;
$post = get_post($id);
$content = apply_filters(‘the_content’, $post->post_content);
echo $content;
?>
</div>
<?php }if( $hour >= 12 or $hour < 6)
if(is_front_page()) { ?>
<div>
<?php
$id=753;
$post = get_post($id);
$content = apply_filters(‘the_content’, $post->post_content);
echo $content;
?>
</div>
<?php }Forum: Everything else WordPress
In reply to: Alternating between two Home PagesIs the below anywhere near?
<?php
$hour = date(‘H’); // hour of the day, 24 hour clock
if( $hour >= 06 or $hour < 18)
if ( is_front_page() {get_option( ‘show_on_front’ );
}
if( $hour >= 18 or $hour < 6)
else {
get_option(753);
}
?>Forum: Plugins
In reply to: [WP Category Tag Cloud] Tag Cloud links not finding pagePerfect! Thank you so much for your help x