Tagged: 

Viewing 27 posts - 1 through 27 (of 27 total)
  • Author
    Posts
  • #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!

    #1026064

    Never mind – I figured it out- you can close this ticket.

    Thanks!

    #1026140

    Hi,

    Thank you for letting us know, we appreciate it!

    Best regards,
    Basilis

    #1026363

    Sorry! 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.
    #1027807

    Hi,

    Try to use the strip_tags function.

    // http://php.net/manual/en/function.strip-tags.php

    
    return strip_tags ( $new_title );
    

    Best regards,
    Ismael

    #1028063

    That 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

    #1029061

    Hi,

    Can you give us a screenshot of what you’re trying to do? Use imgur or dropbox.

    Best regards,
    Ismael

    #1029395

    The 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

    #1030185

    Hi,

    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,
    Ismael

    #1030500

    Thanks! This works on the single event but not on the calendar view itself. Could this be changed as well?

    Thanks!

    #1031529

    Hi,

    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,
    Ismael

    #1031711

    Hi,
    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?
    Thanks

    #1032435

    Hi,

    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,
    Ismael

    #1032621

    Hi 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.
    #1032972

    Hi!

    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!
    Ismael

    #1033043

    Hi Ismael,
    It is still not working in the calendar view for some reason – look at 11/22.

    Thanks

    #1033835

    Hi,

    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,
    Ismael

    #1034057

    Hi 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

    #1034317

    Hi,

    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,
    Ismael

    #1035258

    Hi 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

    #1035959

    Hi,

    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,
    Ismael

    #1036181

    JQuery 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

    #1036451

    Hi,

    This part:

    document.on(
    

    to:

    document.addEventListener(
    

    Best regards,
    Ismael

    #1038979

    Hi Ismael,
    The code is still not being injected into the calendar month view page. :-(

    #1040095

    Hi,

    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,
    Ismael

    #1040392

    Thanks for trying and all of your help.

    #1041051

    Hi,

    Sorry if we can’t be of much help this time. Please open a new thread if you need anything else. I’ll close the thread for now.

    Best regards,
    Ismael

Viewing 27 posts - 1 through 27 (of 27 total)
  • The topic ‘Calendar Pro | single-event.php’ is closed to new replies.