So, to make my story a little short. I'm doing some changes to a client's website, a past freelancer made them a custom theme that made it extremely hard to actually do any changes to the website itself. I'm not that experienced in PHP but I'm learning as I go.
The client asks me to create a slider and I'm using SlideAnything slider plugin that includes shortcodes to be easily added to a page through the editor.
The Shortcode is this "echo do_shortcode("[slide-anything id="2320"]");"
And the way I inserted it in the website was like this:
<section id="feature-courses" class="pt pt-sm-80 feature-section">
<div class="wow fadeInLeft container text-center">
<h2>Cursos de Inglés Destacados</h2>
<div class="spacer-60"></div>
<div class="row">
<?php echo do_shortcode("[slide-anything id="2320"]"); ?>
</div>
</div>
</section>
However, whenever I add it, it crashes the site with a message that says
Parse error: syntax error, unexpected '2320' (T_LNUMBER), expecting ',' or ')' in /home/tuirland/public_html/wp-content/themes/laukoa-tuirlanda/page-homepage.php on line 61
I searched and the shortcodes.php file is inside the WordPress folder.
I recreated my client's website from the ground-up in my local environment and it works flawlessly, however, when I try to do it on his website, the whole thing keeps crashing.
Any reason as to why this is happening on his server but not on my local testing environment? any help would be appreciated. Thanks in advance.
When you using " after the ID atrribute, it's closing the do_shortcode function so it will throw an error. Your code should be:
<?php echo do_shortcode('[slide-anything id="2320"]'); ?>
Or:
<?php echo do_shortcode("[slide-anything id='2320']"); ?>
Related
I have got an issue that I don't know how to debug. Sometimes the output suddenly stops halfway through a PHP script, after a specific echo.
This is a part of the code. After someLonJsonString the output sometimes stops. When the output stops, refreshing the page won't help, so it has something to do with the value also?
<div class="ac-calendar-options">
<div class="timestamp"><?php echo $currentTimestamp;?></div>
<div class="someLongJsonString"><?php echo $someLongJsonString;?></div>
<!-- The output of the script will cut off here -->
<div class="timezone"><?php echo $timezone;?></div>
</div>
Refreshing won't help, but adding some useless echo before the long Json string does help:
<div class="ac-calendar-options">
<div class="timestamp"><?php echo $currentTimestamp;?></div>
<div style="display:none"><?php echo "test"; ?></div>
<div class="someLongJsonString"><?php echo $someLongJsonString;?></div>
<div class="timezone"><?php echo $timezone;?></div>
</div>
When I remove the fix, the problem comes back. Above fix does fix it for that item, but after a while, it pops up again but for another item with another JSON string.
How can I debug this problem? Even temporarily showing the errors for that page/item does fix the problem. And I just don't understand why a simple echo will temporarily fix the problem.
Since we moved to php 7.x from 5.6 this problem magically solved.
Since we moved to php 7.x from 5.6 this problem magically solved. I can't provide any other info I'm afraid, this is just it...
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Edit: Fixed, moved <?php include(haeder.php); ?> to the top and replaced the outsourced part with <?php showheader(); ?>.
I've been creating a little website, and as its menubar started to get full I wanted to "outsource" it to a separate file.
<body>
<div style="width:800px;margin:0px auto">
<!-- outsourced part -->
<div style="height:50px;background-color:#ff0000">
Header
</div>
<!-- end of outsourced part -->
<div style="margin-top:10px;background-color:#00ff00">
hello world
</div>
</div>
</body>
So I copied the outsourced part and pasted it into a new file called header.php and replaced it with
<?php include("header.php") ?>
so now the code is
<body>
<div style="width:800px;margin:0px auto">
<?php include('header.php') ?>
<div style="margin-top:10px;background-color:#00ff00">
hello world
</div>
</div>
</body>
Now when I open the website again the header and everything after it has moved downwards. How can I prevent this from happening? I have PHP 5.6.14 installed on XAMPP and PHP 5.3.3 on a Linux server.
Uploaded the 2 files here
I tested your file and I could see the issue. Usually this is because you got an invisible character in the page. So go into the Chrome debugger, Elements view, and expand the code. You'll find the following before your header <div> tag.
"
"
from the debugger, you can delete it, and you'll see your page displays fine again. So cleanup your 2 php file. One is having an invisible character.
I believe the reason is that your index.php file in UTF8-BOM encoded while the header.php is just UTF8 - make sure to use the same encoding to avoid these issues.
I use mediawiki to take note about the procedure that I follow, the source codes I write in mediawiki are highlighted with the expansion Genshi Syntax HighLight. I want to modify this expansion in mediawiki so it could be created a box above the source code in which it is written the programming language I used. I tried to see expansion sources in my mediawiki but I didn't find the segment in which is "sketch" the <div>. I also saw material about the creation of new expansion in mediawiki to understand how it runs, but I don't understand where the box is created.
I use syntax hightligher like this
some_code
and this is the result in html code generate from mediawiki
<div class="mw-geshi mw-code mw-content-ltr" dir="ltr">
<div class="bash source-bash">
<pre class="de1">
some_code
</pre>
</div>
</div>
I want to prepen the div to first div, like this
<div class='gsh-lang-label'>Language bash</div>
<div class="mw-geshi mw-code mw-content-ltr" dir="ltr">
<div class="bash source-bash">
<pre class="de1">
some_code
</pre>
</div>
</div>
Can you explain me if it is possible to do it and how can I face the problem?
I think ordinary jQuery will solve this problem. Something like:
$(".mw-geshi").each(function(){
$(this).before("<div class='gsh-lang-label'>" +
$(this).children().first().attr("class").split(' ')[0] +
"</div>")
})
Put this in [[MediaWiki:Common.js]], so this script will be run for every user.
I am building a website for a friend who wants to use WordPress for a blog section. I could have just made the whole site as a custom WordPress theme, but I don't like using WordPress because it's bloated, slow, and buggy. So instead I want to add a recent posts module to the site by including the wp-load.php file from the WordPress site and using their functions.
I have made several attempts at creating the module and each method has resulted in an error.
Using a while (have_posts()) loop resulted in a 500 Internal Server Error so I tried using wp_get_recent_posts(array followed by a foreach statement, which doesn't result in the error but instead gets me an "End of file seen and there were open elements."
Here is the link to the site: http://colinthompson.ca/drake/
Here is the code for that section:
<section id="blog">
<h3>recent posts</h3>
<div id="post-wrap">
<?php
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 3
));
foreach ($recent_posts as $post) {
echo '<div class="blog-post">
<div class="post-img">'.get_the_thumbnail($post['ID']).'</div>
<h5>'.$post['post_title'].'</h5>
<p>by <span>'.the_author($post['ID']).'</span></p>
<p>'.the_date(d,m,y).'</p>
<p>'.the_excerpt($post['ID']).'</p>
</div>';
}
?>
</div>
<a id="full-blog" href="#" title="Check out the full blog"><div class="slide-in"><p>full blog</p></div><div class="arrow-shaft"></div><div class="arrow-head"></div><p>read more</p></a>
<a class="next-section" href="#contact" title="Let's get in touch"><div class="slide-in"></div><div class="arrow-shaft"></div><div class="arrow-head"></div></a>
</section>
I tried removing the foreach statement to test for unclosed elements in the html that is being echoed, but the error persisted, resulting in the unclosing of the parent div#post-wrap and grandparent section#blog and general fudging of the rest of the document.
When I removed the wp_get_recent_posts array the page loaded as normal, but without the posts of course.
Maybe I did simply forget to escape something but I don't see it. Any help is appreciated.
Thanks!
Where are you going to display the posts? Where is your friend going to write them?
It seems to me you are much better off including WordPress in it's entirety on just one part of the site.
I deploying my PHP project on CentOS and i using Zend Framework.
I have problem:
When i call an action from another action's view and it displayed is good on Windows Server but not good on CentOS Server. It's not load info in head tag when view source html.
Example:
In file: index.phtml (for index action in Product controller)
<div class="left">
<?php echo $this->action('left', $this->controller,'product',array('currentModule'=>$this->module)); ?>
</div>
<div class='right'>
<?php echo $this->action('list', $this->controller, 'product',array('currentModule'=>$this->module,'back'=> $this->back,'page'=> $this->page)); ?>
</div>
So, we can see. In index.phtml, i called 2 another action (left action and list action in Product controller). Windows is OK but on CentOS, this code is not work.
Please help me for it run on CentOS.
When i was try remove 2 this action:
<div class="left">
//code
</div>
<div class='right'>
//code
</div>
So, it's woking on CentOS :)
Thanks!
Windows migrations to unix based systems usually run into problems like this when you have case sensitivity issues - windows doesn't require case to be correct but unix does. Make sure your folders and php file names have the correct case and try it again - if not give us some of the errors your encountering and we could help more!
By the way, a little off topic here but the action view helper is not efficient, I would suggest looking into custom view helpers and the render view helper instead.