I am using PHPStorm with mix HTML/PHP..
My codes are
<div id="tab2" class="display-none">
<?php include_once "profile/permissions.php"; ?>
</div>
When I use Ctrl+Alt+L for Reformat code then PHP codes remove auto. How can I stop this.
Codes after Reformat.
<div id="tab2" class="display-none">
</div>
I can't understand PHPStorm's problem.
Strange but problem is solved with this change...
<div id="tab2" class="display-none"><?php include_once "profile/permissions.php"; ?></div>
Just removed lines between <?php and <div id="tab2" class="display-none">
Related
I'm trying to display the data of a ACF but I'm getting this error in Visual Studio Code:
This is the entire code. I tried reinstalling the plugin, added PHP to the path but nothing seems to be working.
Single.php
<?php get_header();?>
<div class="container">
<div class="row">
<div>
<img src="<?php the_post_thumbnail_url('thumbnail'); ?>" id="single_header">
<div id="single_content">
<?php if (have_posts()):while (have_posts()):the_post(); ?>
<?php
$fn=get_the_author_meta('first_name');
$lname=get_the_author_meta('last_name');
$email=get_the_author_meta('email');
?>
<h1 class="text=cenetr nt-3 mb-5 text-primary"><?php the_title();?></h1>
<small>Publishor:<?php echo $fn; ?></small>
<p><?php the_content();?></p>
<?php
endwhile;
endif;
?>
<?php previous_post_link(); ?>
<?php next_post_link(); ?>
</div>
<div id="single_extraInfo">
<p>Company: <?php the_field('flight_company'); ?></p>
<p>Date: <?php the_field('flight_date'); ?></p>
<p>Capacity: <?php the_field('flight_capacity'); ?></p>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
On top of what #DaleNguyen adviced above...
Make sure the directory that contains acf plugin is in your Vs Code. Example, instead of only opening the theme directory in Vs Code in which you are probably working, open the entire wp_content directory in your VS Code. That way, when intelephence run in the back-ground, it will be able to reach the plugins folder and acf functions in the acf plugin folder.
In the intelephense, make sure you add wordpress to the list.
#james-serengia answered with one working solution that the ACF plugin folder should be open in the same workspace as the code you are working on and the warning disappears.
Alternatively if that is inconvenient, you can add you can add the ACF stubs to VSCode. It is a bit of messing around but when it is done, it is done. See this explanation.
I created a footer.php file:
<footer class="footer">
<div class="container">
<div class="row">
<div class="footer-col col-md-5">
<p>Copyright © 2018 Nens Events.</p>
</div>
</div>
</div>`
and it is located on a folder like this one:
/php/footer.php
All I want is to read it on a subfolder like this one: /events/na/1.php
but when I use this code, it doesn't read the footer.php file, does someone know what I am doing wrong?
<?php
echo file_get_contents("/php/footer.php");
?>
Use include() or require() function to join your codes into your script.
So the code for reading(in your terms) will be like this
<?php include 'php/footer.php'; ?>
If the site is on root page, use absolute path like this.
<?php include '/php/footer.php'; ?>
It should work! Give a try.
Use require('php/footer.php') for better coding.
I have a html structure like below, I want to place my custom header at a random position.
<div class="div1">
<div class="div2">
<?php echo do_shortcode('[header]'); ?>
</div>
<div class="div3"></div>
</div>
But it always make my header go to the bottom.
<div class="div1">
<div class="div2">
//I want the header to stay here
</div>
<div class="div3"></div>
<header>......</header>
</div>
However I place it, the header always go to the bottom, please give advice if you experience it.
UPDATE:
In my case, a specific class removed helped. Thanks everybody.
I would like to remove the extra markup that is around the generated paragraph items.
<h1>
<div class="field field-name-field-title field-type-text field-label-hidden">
<div class="field-items">
<div class="field-item even">Title</div>
</div>
</div>
</h1>
I would like it to display like this:
<h1>Title</h1>
I’ve not had any luck trying some of the suggestions in the Paragraphs issues https://www.drupal.org/node/2251909 such as editing the following files:
paragraphs-item.tpl.php
paragraphs-items.tpl.php
paragraphs.theme.inc
Does anyone have any experience with this module and be able to offer some assistance?
You can use strip_tags() to remove the html tags.
<h1><?php print strip_tags(render($content['YOUR_FIELD'])); ?></h1>
or
<?php print strip_tags(render($content['YOUR_FIELD']), "<h1>"); ?>
Hope this helps you.
Maybe the title of my question is not very correct, i'm very sorry.
I have Windows 7 x64 with eclipse helios + PDT 3.0.0v20110516. I've created a php file with this content:
<?php if (count($travels)):?>
<ul class="real-height ribbon-m " id="travels">
<?php foreach($travels as $travel):?>
<li class="message t-ruler fitted ribbon-l">
all code is highlighted correctly, but if I try to insert new html or php tags after ?> my editor gets crazy, it types anything in the correct or any other lines, so I can't add new php code.
Does anybody know how to solve it?
Thank you very much
This is called alternative syntax: You still need to end each statement:
<?php if (count($travels)>=1):?>
<ul class="real-height ribbon-m " id="travels">
<?php foreach($travels as $travel):?>
<li class="message t-ruler fitted ribbon-l">
<?php endforeach;?>
<?php endif;?>
try this code:
<?php if (count($travels)):?>
<ul class="real-height ribbon-m " id="travels">
<?php foreach($travels as $travel):?>
<li class="message t-ruler fitted ribbon-l"> <?php echo $travel;?></li>
<?php endforeach; ?>
</ul>
if you are already doing this try to post what exactly are the tags you are writing.
This may be related to the following annoying Eclipse bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359473