Tagged: calendar pro
-
AuthorPosts
-
October 23, 2018 at 4:45 pm #1025518
I have modified this file that is included in the Enfold theme to show a custom field for the post title if the custom field exists. I have the following in the above mentioned file:
<?php
$html_title = get_post_meta($post->ID, “HTML_title”, true);
if ($html_title) { ?>
<h1><?php echo $html_title; ?></h1>
<?php } else { ?>
<h1><?php the_title(); ?></h1>
<?php } ?>The custom field is HTML_title which is used on the event. It is not working. I’m assuming I need to add a query of some sort to get this custom field to display on this page?
Please advise.
Thanks!October 24, 2018 at 7:19 pm #1026064Never mind – I figured it out- you can close this ticket.
Thanks!
October 24, 2018 at 10:33 pm #1026140Hi,
Thank you for letting us know, we appreciate it!
Best regards,
BasilisOctober 25, 2018 at 2:58 pm #1026363Sorry! Spoke too soon.
Is there a way to remove the HTML from the <title></title> tag in the the post page <head>? Here is the filter I am using while calling the “closed” custom field in my child theme functions file.
This code works great on a a standard blog post, but not on an event entry(post).
Thanks!
add_filter( ‘the_title’, ‘wpse33385_filter_title’, 10, 2 );
function wpse33385_filter_title( $title, $post_id )
{
if( $new_title = get_post_meta( $post_id, ‘closed’, true ) )
{
return $new_title;
}
return $title;
}- This reply was modified 6 years, 1 month ago by xyzb.
October 30, 2018 at 2:44 am #1027807Hi,
Try to use the strip_tags function.
// http://php.net/manual/en/function.strip-tags.php
return strip_tags ( $new_title );
Best regards,
IsmaelOctober 30, 2018 at 3:21 pm #1028063That works but that is not what I wanted. I want to add HTML to the event post title so if we are closed that day, it will be red and bold in the calendar, the list and in the post itself.
Other ideas?
Thanks
November 2, 2018 at 8:12 am #1029061Hi,
Can you give us a screenshot of what you’re trying to do? Use imgur or dropbox.
Best regards,
IsmaelNovember 3, 2018 at 2:53 am #1029395The events cal uses the event(post) title on the calendar. When we are closed, I want the title to be styled so it is red, etc. I am able to do this using a filter in the functions file but it retains the markup in the tile which is displayed in the browser<head> tag.
Take a look at the page included.
Thanks
November 6, 2018 at 5:17 am #1030185Hi,
Thanks for the info. Please remove the mark tag and use this script in the functions.php file instead:
add_action('wp_footer', 'ava_color_closed_event', 9999); function ava_color_closed_event() { ?> <script> (function() { const et = document.querySelector('.tribe-events-single-event-title'); if(et && et.textContent == 'Closed' ) { et.style.color = '#c20b1a'; } })(); </script> <?php }
Best regards,
IsmaelNovember 6, 2018 at 6:38 pm #1030500Thanks! This works on the single event but not on the calendar view itself. Could this be changed as well?
Thanks!
November 9, 2018 at 5:59 am #1031529Hi,
Thanks for the update. Try this script instead:
add_action('wp_footer', 'ava_color_closed_event', 9999); function ava_color_closed_event() { ?> <script> (function() { let et = document.querySelector('.tribe-events-single-event-title'); et = et ? et : document.querySelector('.tribe-events-month-event-title a'); if( ( et ) && ( et.textContent == 'Closed' || et.textContent == 'Library Closed' ) ) { et.style.color = '#c20b1a'; } })(); </script> <?php }
Best regards,
IsmaelNovember 9, 2018 at 4:37 pm #1031711Hi,
Couple of things – “let” is invalid according to my PHP editor so I changed it to “const”. The new script didn’t work – it didn’t change the title color on the event page or the calendar page title/link so I went back to the first script you had sent.Other ideas?
ThanksNovember 12, 2018 at 5:59 am #1032435Hi,
That is a javacript code wrapped in php hook, so I’m not sure how you get that error. Can you give us a screenshot? Try this code instead.
add_action('wp_footer', 'ava_color_closed_event', 9999); function ava_color_closed_event() { ?> <script> (function() { const et = document.querySelector('.tribe-events-single-event-title'); const etm = document.querySelector('.tribe-events-month-event-title a'); if( ( et && et.textContent == 'Closed' ) || ( etm && etm.textContent == 'Library Closed' ) ) { etc = et ? et : etm; etc.style.color = '#c20b1a'; } })(); </script> <?php }
Best regards,
IsmaelNovember 12, 2018 at 3:35 pm #1032621Hi Ismael,
Here is a summary of where we are at-
1.
add_action(‘wp_footer’, ‘ava_color_closed_event’, 9999);
function ava_color_closed_event() {
?>
<script>
(function() {
let et = document.querySelector(‘.tribe-events-single-event-title’); This throws a 500 server error.
et = et ? et : document.querySelector(‘.tribe-events-month-event-title a’);
if( ( et ) && ( et.textContent == ‘Closed’ || et.textContent == ‘Library Closed’ ) ) {
et.style.color = ‘#c20b1a’;
}
})();
</script>
<?php
}
_________________________________________________________________________________________________________
2. This doesn’t work-
add_action(‘wp_footer’, ‘ava_color_closed_event’, 9999);
function ava_color_closed_event() {
?>
<script>
(function() {
const et = document.querySelector(‘.tribe-events-single-event-title’);
const etm = document.querySelector(‘.tribe-events-month-event-title a’);
if( ( et.textContent == ‘Closed’ || etm.textContent == ‘Library Closed’ ) ) {
et.style.color = ‘#c20b1a’;
etm.style.color = ‘#c20b1a’;
}
})();
</script>
<?php
}
________________________________________________________________________________________________________
3. This only works on the single event page itself, but not in the calendar view.
add_action(‘wp_footer’, ‘ava_color_closed_event’, 9999);
function ava_color_closed_event() {
?>
<script>
(function() {
const et = document.querySelector(‘.tribe-events-single-event-title’);
if(et && et.textContent == ‘Closed’ ) {
et.style.color = ‘#c20b1a’;
}
})();
</script>
<?php
}- This reply was modified 6 years, 1 month ago by xyzb.
November 13, 2018 at 12:38 pm #1032972Hi!
Sorry about that. I adjusted the code a bit and it worked properly on my installation. Please try it again.
// https://kriesi.at/support/topic/calendar-pro-single-event-php/#post-1032435
Cheers!
IsmaelNovember 13, 2018 at 3:58 pm #1033043Hi Ismael,
It is still not working in the calendar view for some reason – look at 11/22.Thanks
November 15, 2018 at 8:51 am #1033835Hi,
Odd. It’s working properly on my end. Please try this again:
add_action('wp_footer', 'ava_color_closed_event', 9999); function ava_color_closed_event() { ?> <script> (function() { document.addEventListener( "DOMContentLoaded", () => { const et = document.querySelector('.tribe-events-single-event-title'); const etm = document.querySelector('.tribe-events-month-event-title a'); if( ( et && et.textContent == 'Closed' ) || ( etm && etm.textContent == 'Library Closed' ) ) { etc = et ? et : etm; etc.style.color = '#c20b1a'; } }); })(); </script> <?php }
If it doesn’t work, please post the WP login details in the private field. Make sure that the Appearance > Editor panel is accessible.
Best regards,
IsmaelNovember 15, 2018 at 6:00 pm #1034057Hi Ismael,
Your last bit of code did not work on with the single event listing or the calendar view.
I have this running on localhost, all plugins disabled except the calendar pro software, running a child theme with just your code in the child functions file. As mentioned, works on the single event page but not in the main calendar view. What is your local config, maybe I can reproduce it?Thanks
November 16, 2018 at 8:05 am #1034317Hi,
I just created two containers with the specified class attributes and place the texts inside.
<div class="tribe-events-single-event-title">Closed</div> <div class="tribe-events-month-event-title"><a href="#">Library Closed</a></div>
Try to replace the “DOMContentLoaded” event with “load”.
Best regards,
IsmaelNovember 19, 2018 at 6:37 pm #1035258Hi Ismael,
It is stripping out the injected JS style on the calendar view. I can see the style in the single event but not in calendar view.Thanks
November 21, 2018 at 10:48 am #1035959Hi,
Did you set jQuery to load in the footer? Please let us know once the site is live so that we can test it. You can also try to replace “on” with “addEventListener”.
Best regards,
IsmaelNovember 21, 2018 at 5:10 pm #1036181JQuery is not set to load in the footer.
Not sure where I should be see this?
You can also try to replace “on” with “addEventListener”.Thanks
November 22, 2018 at 11:35 am #1036451November 29, 2018 at 3:43 pm #1038979Hi Ismael,
The code is still not being injected into the calendar month view page. :-(December 3, 2018 at 4:35 am #1040095Hi,
Weird. Unfortunately, we can’t help any further if we can’t access the site. Please hire a freelance developer or contact our partner, Codeable.
// https://kriesi.at/contact/customization
Best regards,
IsmaelDecember 3, 2018 at 4:55 pm #1040392Thanks for trying and all of your help.
December 5, 2018 at 3:21 am #1041051 -
AuthorPosts
- The topic ‘Calendar Pro | single-event.php’ is closed to new replies.