Why this is showing me nothing in Wordpress? - wordpress

Why this is show me nothing??
I'm totally lost =(
<?php function calc_shortcode(){ ?>
<div>
<form>
<h3>Price High</h3>
<input name="priceHigh" type="text" />
<h3>Price Low</h3>
<input name="priceLow" type="text" />
<h3>Price Up</h3>
<input name="priceUp" type="text" />
<h3>Price Down</h3>
<input name="priceDown" type="text" /></br>
<input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
</form>
</div>
<?php
}
add_shortcode('calc_pat', 'calc_shortcode');
Thanks for helping guys!

To use shortcode you need to call it. Read more here https://developer.wordpress.org/reference/functions/add_shortcode/ and https://developer.wordpress.org/reference/functions/do_shortcode/
echo do_shortcode('[calc_pat]');

The php labels are wrongly placed there, try doing this:
<?php
function calc_shortcode(){
<div>
<form>
<h3>Price High</h3>
<input name="priceHigh" type="text" />
<h3>Price Low</h3>
<input name="priceLow" type="text" />
<h3>Price Up</h3>
<input name="priceUp" type="text" />
<h3>Price Down</h3>
<input name="priceDown" type="text" /></br>
<input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
</form>
</div>
}
add_shortcode('calc_pat', 'calc_shortcode');
?>
Check if that works

Please give try to below code, it should work:
function calc_shortcode(){
echo '<div>
<form>
<h3>Price High</h3>
<input name="priceHigh" type="text" />
<h3>Price Low</h3>
<input name="priceLow" type="text" />
<h3>Price Up</h3>
<input name="priceUp" type="text" />
<h3>Price Down</h3>
<input name="priceDown" type="text" /></br>
<input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
</form>
</div>';
}
add_shortcode('calc_pat', 'calc_shortcode');
you can also add ob_start(); and ob_get_clean();

Try below code :
<?php function calc_shortcode()
{
ob_start();
?>
<div>
<form>
<h3>Price High</h3>
<input name="priceHigh" type="text" />
<h3>Price Low</h3>
<input name="priceLow" type="text" />
<h3>Price Up</h3>
<input name="priceUp" type="text" />
<h3>Price Down</h3>
<input name="priceDown" type="text" /></br>
<input name="submit" type="submit" value="Calculate" class="btn btn-primary" />
</form>
</div>
<?php
echo ob_get_clean();
die();
}
add_shortcode('calc_pat', 'calc_shortcode');

Related

How to get pop up box after comment submitted in custom comment box?

I made custom file to add comment on posts, this file only contains a comment box. Now I want to show pop up dialogue box when user post a comment, this is my form
<form action="https://m.punjabidharti.com/wp-comments-post.php" method="post" id="commentform">
<p>
<input type="text" name="author" id="author" class="textarea" value="" size="22" tabindex="1" />
<label for="author">
Name </label>
(required)
</p>
<p>
<input type="text" name="email" id="email" value="" size="22" tabindex="2" class="textarea" />
<label for="email">
E-mail </label>
(required)
</p>
<p>
<label for="comment"><strong>Your Comment</strong></label>
<br />
<textarea name="comment" id="comment" cols="50" rows="10" tabindex="4" class="textarea"></textarea>
</p>
<p>
<input name="submit" id="submit" type="submit" tabindex="5" value="submit" class="Cbutton" />
<input type="hidden" name="comment_post_ID" value="<?php echo $_GET["img"]; ?>" />
</p>
<p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="9dc14cd05a" /></p>
<p style="display: none;"><input type="hidden" id="ak_js" name="ak_js" value="165" /></p>
<p>Comment moderation is enabled. Your comment may take some time to appear.</p>
</form>

Pure css nothing has margin

<form className="pure-form">
<fieldset>
<input ref="email" type="email" placeholder="Email"
value={this.state.emailInput}
onChange={this.handleChange}
/>
<input ref="password" type="password" placeholder="Password"
value={this.state.passwordInput}
onChange={this.handleChange}
/>
<label htmlFor="remember">
<input ref="remember" id="remember" type="checkbox" /> Remember me?
</label>
<button onClick={this.handleLoginClick} type="submit" className="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
I just copy-pasted the example form from Purecss.io.
How come everything sticks together? Why do they have no margin?
You have the classes incorrectly added:
<form className="pure-form">
should be
<form class="pure-form">
...and so on.
<link href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css" rel="stylesheet" />
<form class="pure-form">
<fieldset>
<input red="email" type="email" placeholder="Email" />
<input ref="password" type="password" placeholder="Password" />
<label htmlFor="remember">
<input ref="remember" id="remember" type="checkbox" />Remember me?
</label>
<button onClick={this.handleLoginClick} type="submit" class="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
Paulie_D is correct if you want to call any css class on any html tag then you need to follow the syntax like this
<tag class="classname"></tag>
Eg:
<form class="pure-form">
form elements goes here
</form>

Set a Virtual Page View with Universal GA

This is my HTML from. and i'm trying to set a Virtual Page View when submitting the form but i just can't make it work.
Pls advice
<form id="frmContact" action="post.php" method="post">
<div class="form-right-pnl">
<input type="text" class="required name" size="40" placeholder="×©× ×ž×œ×:" name="full_name">
<input type="text" class="required phone" size="40" placeholder="טלפון:" name="phone">
<input type="text" class="required email" size="40" placeholder='דו×"ל:' name="email">
<span>מ×שר קבלת ×—×•×ž×¨×™× ×¤×¨×¡×•×ž×™×™×</span>
<input type="checkbox" class="radio_btn" name="selling_a_property" checked value="Yes"/>
</div>
<div class="form-left-pnl" id='basic-modal'>
<input class="ddl_list" type="submit" value="" onClick=”_gaq.push([‘_trackEvent’, ‘Forms’, ‘Submit’]);” />
</div>
<div class="clear"></div>
</form>
Change this line
<input class="ddl_list" type="submit" value="" onClick=”_gaq.push([‘_trackEvent’, ‘Forms’, ‘Submit’]);” />
for
<input class="ddl_list" type="submit" value="" onClick=”_gaq.push(['_trackPageview', '/virtual-page-view-on-click-submit-button']);” />

Search for products only in parent class

How do I edit the search form below to search only in a specific category on woocommerce?
<form role="search" method="get" id="searchform" action="http://url-is-here.com">
<div>
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" placeholder="Search for products" />
<input type="submit" id="searchsubmit" value="Search" />
<input type="hidden" name="post_type" value="product" />
</div>
</form>
Did you try:
<form role="search" method="get" id="searchform" action="http://url-is-here.com">
<div>
<label class="screen-reader-text" for="s">Search for:</label>
<input type="text" value="" name="s" id="s" placeholder="Search for products" />
<input type="submit" id="searchsubmit" value="Search" />
<input type="hidden" name="post_type" value="product" />
<input type="hidden" name="cat" id="cat" value="5" />
</div>
</form>
This should limit the results to category with an id of 5.

Joomla 3.2 Multiple submit buttons in component

iam struggeling with two submit buttons in my component form.
<button type="submit" class="button"><?php echo JText::_('Save1'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_1" />
<button type="submit" class="button"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_2" />
The problem ist, each button leads to the controllers function save_2.
If iam changing the order to
<button type="submit" class="button"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_2" />
<button type="submit" class="button"><?php echo JText::_('Save1'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save_1" />
both buttons are executing the function save_1 in the controller.
It is always executing only the task of the last button. What is wrong here?
I would like to execute controllers task1 when I use the button task1, and execute controllers task2 when I use the button task2.
thx Perino
Thank you! I did it now on a similar way:
in the view (i worked with different sub-layouts in this view), id did now
<button type="submit" class="button" name="save_1"><?php echo JText::_('Save1'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save" />
<button type="submit" class="button" name="save_2"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" name="task" value="data.save" />
Then in the controller i did
public function save()
{
If (Isset($_POST['save_1']))
{
echo "Button 1 saved"; // here you can do your task for button1
}
If (Isset($_POST['save_2']))
{
echo "Button 2 saved"; //here you can do your task for button2
}
I hope this can also help anybody with same problem.
it looks like both your submit-buttons are in the same form. So the last taks - input will overwrite the first. So either you need to make two forms (probably not what you want?) or you need to handle the click-event depending on which submit-button is clicked, and update the task-variable accordingly, something like:
<button type="submit" class="button"><?php echo JText::_('Save2'); ?></button>
<input type="hidden" name="option" value="com_mycomponent" />
<input type="hidden" id="formtask" name="task" value="data.save_2" />
<button type="submit" class="button"
onclick="document.getElementById('formtask').value='data.save_1'">
<?php echo JText::_('Save1'); ?></button>

Resources