Adding codes to Functions.php causes website to go down.

Home Forums Calendar Products Events Calendar PRO Adding codes to Functions.php causes website to go down.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1109914
    Lyle
    Participant

    I have two websites, both under the same server and both uses the events calendar plugin and the same theme called Graphy from ThemGraphy. Only difference is that in this particular site (malaysiaperforms.com) it has the fb & community add ons.

    Now without editing the functions.php , everything seems to be working fine except the the site title was “Upcoming Events | Events | Malaysia Performs ” . So to change browser title, i used this coding and on its own without any edits, it works as how it should be.

    But having a coding display “Month View Page” is not what i was looking for. So i tried to change

    // Month view Page
    	elseif ( tribe_is_month() && !is_tax() ) {
    		$title = 'Month view page';

    to

    
    // Month view Page
    	elseif ( tribe_is_month() && !is_tax() ) {
    		$title = '<?php bloginfo( 'name' ); ?> | Month view page';

    Which i hoped that it will show “Site name | Month view page” and to edit all other views accordingly. Now with “$title = ‘<?php bloginfo( ‘name’ ); ?> | Month view page’;`” set, i then save the file but as soon as i did that… MP.com fails to load.

    Even going to the backend and uploading the original functions.php has left my site unable to load at the moment of this post (my hosting theme is currently checking on it). Additionally I was able to fix this by renaming the Graphy theme folder to force it to deactivate and activate the default twentysixteen theme.

    Now doing that does not make a difference.

    #1109930
    Lyle
    Participant

    This reply is private.

    #1109933
    Lyle
    Participant

    right now only two themes are installed. Graphy (which i want to use) and TwentySixteen.

    Graphy and 2016 are at default and no additional coding has been added. Also like what i had mentioned earlier, when i save the function.php after inputting the “site title” codes, the page stops displaying and i then have to delete the whole theme folder (overwriting just the function.php does not work)

    #1109951
    Josh
    Participant

    Hey Lyle,

    Thanks for reaching out to us!

    Try changing your code to:

    
    // Month view Page
    elseif ( tribe_is_month() && !is_tax() ) {
    $title = bloginfo( 'name' ) . ' | Month view page';
    

    And see if that addresses your issue here.

    Thanks!

    #1109962
    Lyle
    Participant

    original function coding

    modified coding

    now giving this error

    Parse error: syntax error, unexpected $end in /_/themes/graphy/functions.php on line 297

    however when i remove this coding

    add_action( 'pre_get_posts', 'tribe_post_date_ordering', 51 );
    
    function tribe_post_date_ordering( $query ) {
    	if ( ! empty( $query->tribe_is_multi_posttype ) ) {
    		remove_filter( 'posts_fields', array( 'Tribe__Events__Query', 'multi_type_posts_fields' ) );
    		$query->set( 'order', 'DESC' );
    	}

    my page is able to load. The above coding is something that I would like to use as I am using the feed wordpress makes to do an auto tweet with IFTTT.

    Next issue I have is that when visiting the site, site title is “Malaysia Performs | Upcoming Events” ; correct in both list/month view until one clicks on “next events” or “previous events” . Both output it as “|Upcoming Events – Page 2 – Malaysia Performs ” and “|Upcoming Events – Malaysia Performs ”

    Output should be “Malaysia Performs | Upcoming Events | Page #” in both the list/month when one forwards the page in either view.

    Additionally how do i code it so that single event pages such as this displays the title as ” Name of event | Site Title” or “Name of event | start DD MM – end DD MM | Site Title ”

    Thank you very much for the help

    • This reply was modified 10 years ago by Lyle. Reason: minor edits
    #1110377
    Lyle
    Participant
    // Single events
    	if ( tribe_is_event() && is_single() ) {
    		$title = 'Single event page';
    	}

    when i remove the above code which is giving all my single event pages the title of “Single Event Page” , i am getting this error

    Parse error: syntax error, unexpected T_ELSEIF in _/themes/graphy/functions.php on line 241

    Now line 241 reads as such

    if ( tribe_is_event() && is_single() ) {

    i put back the above code and modify it to be as such

    // Single events
    	if ( tribe_is_event() && is_single() ) {
    		$title = ' <?php the_title(); ?>';
    	}

    this outputs it to “<?php the_title(); ?>” as the title. Removing the ‘ ‘ from $title = , gives me this

    Parse error: syntax error, unexpected '<' in _/themes/graphy/functions.php on line 242

    And that line is

    $title = <?php the_title(); ?>;

    How do i output the event title on a single event?

    #1110502
    Josh
    Participant

    Hey Lyle,

    To set expectations on this one, I am limited in the support I’m able to provide for customizations such as this.

    However, I can help to give some direction on addressing the malformed php codes that you’re currently trying to use in your file. To start, the first snippet that you have where it hooks into “pre_get_posts” that gives you the unexpected $end, ensure that you have closing bracket “}” to close that function. It should be the next line below what you’ve provided above. If that is missing, you’ll get that type of error.

    Also, for the $title variable that you’re trying to assign, there are two key issues with your current approach. First, you don’t need to reopen or close the “<?php” tags there. It should just be the function name. Second, the function you’re currently using ( the_title() ) echos the value so you’ll get that value dumping out on the screen somewhere else that you don’t intend. What you want to use when assigning the title to a variable would be “get_the_title()”.

    So, the above would be properly written as:

    
    $title = get_the_title();
    

    Let me know if this helps.

    Thanks!

    #1110813
    Lyle
    Participant

    many thanks. this has solved most of the problems i was having.

    I will engage with others to resolved some kinks

    #1111427
    Josh
    Participant

    Hey Lyle,

    No problem, happy to help!

    I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new one.

    Thanks!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Adding codes to Functions.php causes website to go down.’ is closed to new replies.