Home › Forums › Calendar Products › Events Calendar PRO › Adding codes to Functions.php causes website to go down.
- This topic has 8 replies, 2 voices, and was last updated 10 years ago by
Josh.
-
AuthorPosts
-
May 3, 2016 at 3:00 am #1109914
Lyle
ParticipantI 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.
May 3, 2016 at 4:54 am #1109930Lyle
ParticipantThis reply is private.
May 3, 2016 at 4:58 am #1109933Lyle
Participantright 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)
May 3, 2016 at 6:08 am #1109951Josh
ParticipantHey 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!
May 3, 2016 at 6:42 am #1109962Lyle
Participantnow giving this error
Parse error: syntax error, unexpected $end in /_/themes/graphy/functions.php on line 297however 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
May 4, 2016 at 5:26 am #1110377Lyle
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 241Now 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 242And that line is
$title = <?php the_title(); ?>;How do i output the event title on a single event?
May 4, 2016 at 8:47 am #1110502Josh
ParticipantHey 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!
May 4, 2016 at 8:15 pm #1110813Lyle
Participantmany thanks. this has solved most of the problems i was having.
I will engage with others to resolved some kinks
May 6, 2016 at 7:09 am #1111427Josh
ParticipantHey 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!
-
This reply was modified 10 years ago by
-
AuthorPosts
- The topic ‘Adding codes to Functions.php causes website to go down.’ is closed to new replies.
