WordPress shortcode display as plain text - wordpress

I have a custom templates and I used custom shortcodes to displayed it in the page. But the shortcode is not working, its displayed as plain text only. I already deactivate and reactive the plugins but still have same issue.
I'm using this [info_box_calculator] but it display as plain text or sometimes it gives me a blank page
How to fix this?
function info_box_calculator(){
ob_start();
get_template_part('page-calcu-info-box');
return ob_get_clean();
}
add_shortcode('info_box_calculator', 'info_box_calculator');
Link

Related

hide shortcode when one is empty

I created a shortcode to be personalised directly in product page. I was wondering if there was a way to not show the shortcode if one of them is empty ? I saw it's not recommended to work directly and check if shortcode is empty but i don't find the solution anywhere.
What i need to check (if these shortcode is empty) : [tech_img1] [tech_img2] [tech_img3] [tech_text1][tech_text2] and [tech_img3]
For example : For each product, i can enter an url img saved in this shortcode [tech_img] and text saved in this shortcode [tech_text]. However if one of the shortcode is empty (no data in it), the function custom_tech shoudn't be display in front
I used this tutorial to add and save custom field in a product page : https://remicorson.com/mastering-woocommerce-products-custom-fields
I made a custom shortcode to fuse all the shortcode i need to display
function custom_tech() {
echo do_shortcode('<div class="flextech"><img class="picfit" src="[tech_img1]" alt="tech_image1"><p class="tech-block">[tech_text1]</p><img class="picfit" src="[tech_img2]" alt="tech_image1"><p class="tech-block">[tech_text2]</p><img class="picfit" src="[tech_img3]" alt="tech_image3"><p class="tech-block">[tech_text3]</p></div>'); } add_shortcode( 'my_custom_tech', 'custom_tech');

Shortcode not working in custom wordpress theme

I installed a Plugin in a wordpress site which uses some shortcode (like metaslider). But when I insert the shortcode in the page it is not displayed the content of the shortcode but only the string [shortcode].
Have I to insert something in the function.php file of the theme I use? (it is a custom theme)
Thanks in advance
If only the string [shortcode] is shown instead of the actual plugin output, it seems that the output of your pages does not use the do_shortcode filter properly. Without exactly knowing what's happening, try the following:
function filter_content_example($content) {
$content = do_shortcode($content);
return $content;
}
add_filter('the_content', 'filter_content_example');
This is only a first guess. Without further investigation i could not solve that problem.

Content written in the Page edit box not showing in the published page in Wordpress

I am not sure what I am missing. Please guide me and I apologize if my knowledge is too less.
I have a home template file i.e. template-home.php which actually contains nothing for now and is only containing the following lines ->
<?php
/**
* This is the front page code
* Template Name: HomePage
*/
get_header();
get_footer();
?>
I have created a page from wp admin and given the page title "Home" then I selected template "Homepage" for this page I have created from wp admin. Hence I have set the static front page to display "Home". Its perfectly showing the Home page as front page. But when I am giving any content in the edit box of the page "Home" from wp-admin and updating, those contents are not displaying in frontend. But if I put any content in the "Homepage" template , only then its getting displayed. I am giving an example what I tried below-
When I am giving the following in the page edit box then nothing is displayed in real.
[rev_slider_vc alias="homebanner" title="Home Slideshow"]
For your information the above is shortcode of revolution slider which is working perfectly , if I use it in any post. So the shortcode has no error for sure. Another thing whatever I write in the content box is actually not getting displayed in real.
Now the slider code, if I am putting directly into the Home template i.e. template-home.php then slider is getting displayed. The code is as follows ->
<?php
/**
* This is the front page code
* Template Name: HomePage
*/
get_header();
// Revolution Slider
putRevSlider('homebanner', 'homepage');
get_footer();
?>
Though my purpose is getting served well by putting code into the template file directly. But I want that the content I put in the edit box of the page from wp admin can get displayed in real. So what I need to do for that ?
Read https://codex.wordpress.org/The_Loop and https://developer.wordpress.org/reference/functions/the_content/
You need a loop and you need the_content to grab the content from the text editor.
A very basic example:
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
the_content();
//
} // end while
} // end if
?>
Work with that first with some plain text to test the loop.
Then add your shortcode for the slider [rev_slider_vc alias="homebanner" title="Home Slideshow"] in the text editor. And, look at the docs for the slider on how to place the function putRevSlider('homebanner', 'homepage'); directly in the page template file, if you want to do that rather than using the shortcode in the editor.
See https://codex.wordpress.org/Theme_Development for how WordPress themes are structured and the types of basic files you need in each theme, i.e. index.php, style.css, etc.

Wordpress Plugin Shortcode Disturbs Page Content Put Alongwith it into the Editor

I have created a plugin with short code now when I access the plugin through short code it works fine issue is that when I put some text above the short code that text goes below the plugin when i view the page.
Here is code that I put into wordpress editor:
<p>Unlock your device safely in 3 steps</p>
[CUSTOMSLIDER]
you can see the plugin shortcode is on second row but static text is on first row but when I will view the page the text goes below the plugin. here you can see its view. you can see the slider is at top and the text is below slider though these were opposite in original source.
in your custom plugin, instead of:
echo "content";
change that to:
$variable .= "content";
return $variable
from:
http://wordpress.org/support/topic/shortcode-moving-to-top-of-entry-content

widgets_on_pages not working

Hello i'm using widgets_on_pages to place widgets on pages, i installed it and added a widget to the panel in my admin section, then i added [widgets_on_pages id=2] ("its the 2nd sidebar and it said i should add this") into my html on the place where the widget should appear but it only shows the code i added in pure text, nothing else happens, anyone know what i'm doing wrong?
If I understand correctly then the following applies... if not, apologies.
You should not need to do it this way. It seems that Vincent, you are trying to add the shortcode into a theme php file... this is incorrect and the shortcode is for adding into the page/post content by the post/page editor.
To add a Widgets on Pages sidebar to a template then v 0.0.7 (I believe) has built in template tags (see link text). This should allow you to add the following I think
<?php widgets_on_template("2"); ?>
Try this
<?php echo do_shortcode('[widgets_on_pages id=2]'] ?>

Resources