Wordpress do_shortcode function implementation after loop - wordpress-theming

I am doing a project on wordpress theme. Wordpress has a function call do_shortcode but when I implement it, the code is not working. The output of the $metagallery is
[Best_Wordpress_Gallery id="1" gal_title="Gallery 1"]
Why isn't it working when I echo using the function do_shortcode?
<?php
$metagallery = get_post_meta($id, '_jdev_custom_meta', true);
?>
<?php if ($metagallery!="") { ?>
<div class="row clearfix galleryarea" >
<div class="col-md-10 col-md-offset-1 column">
<div class="row clearfix" >
<div class="col-md-12 column">
<div class="gallerycontent">
<h2>Gallery</h2>
<?php
echo do_shortcode($metagallery); ?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>

Alright. Solved it. When i view in html, it is:
[Best_Wordpress_Gallery id="1" gal_title="Gallery 1"]
But when viewing in source code, it looks like this:
[Best_Wordpress_Gallery id="1" gal_title="Gallery 1"]
The double quote changes to special characters. Thus have to decode it.
By applying htmlspecialchars_decode it solve the problem
<?php echo do_shortcode((htmlspecialchars_decode($metagallery))); ?>

Related

Social share buttons on success.phhtml magento2

Can anyone guide me how can i add social share buttons in Magento 2 ?
In success.phtml i have discounted code on that . I want to just send that on social share.
Below is the file that want create. If any module or custom code then help me anyone?
SHare your code i have already done but i am getting issue how to add below sharing option using custom coding.
Below is the success.phtml file
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<?php /** #var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<div class="checkout-success">
<div class="main-inside-checkout">
<?php if ($block->getOrderId()) :?>
<div id="main-checkout-first">
<?php if ($block->getCanViewOrder()) :?>
<h1 class="order_status">Your order is Confirmed!</h1>
<img src="<?php echo $block->getUrl("pub/media/icon/")?>order-imge.jpg"/>
<p class="order-number"><?= $block->escapeHtml(__('Your order number is: %1.', sprintf('<strong>%s</strong>', $block->escapeUrl($block->getViewOrderUrl()), $block->getOrderId())), ['a', 'strong']) ?></p>
<?php else :?>
<p><?= $block->escapeHtml(__('Your order # is: <span>%1</span>.', $block->getOrderId()), ['span']) ?></p>
<?php endif;?>
<h5><?= $block->escapeHtml(__('Get 25% Off your next order')) ?></h5>
<p class="order-disc-details">When your friends use your referral code to place their first order,you'll both get <span class="off-percentage">25% Off</span>. It's a win win 🙂</p>
</div>
<div id="main-checkout-second">
<p class="main-input-checkout"><input type="text" value="LGL174" id="discounted-code"><button class="button-for-copy" onclick="copyToClipBoard()">COPY</button></p>
</div>
<div id="main-checkout-second">
Share via Whatsapp
</div>
<?php endif;?>
<?= $block->getAdditionalInfoHtml() ?>
<div class="actions-toolbar">
<div class="primary">
<a class="action primary continue" href="<?= $block->escapeUrl($block->getContinueUrl()) ?>"><span><?= $block->escapeHtml(__('Continue Shopping')) ?></span></a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function copyToClipBoard() {
var content = document.getElementById('discounted-code');
content.select();
document.execCommand('copy');
}
</script>
If anyone have idea then please let me know

CK editor data displaying with html tags in php

CK editor data displaying with html tags in php
please help me...
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header text-uppercase">Product Description</div>
<?php echo $result['description'];?>
</div>
</div>
</div>
it's displaying like this
but should displaying like this
Please use this "html_entity_decode"
Example:
$str = '<a href="https://www.w3schools.com">w3schools.com</a>'; echo html_entity_decode($str);

I've tried converting a HTML site to WordPress but only the content is displayed and the CSS is not working

I want a HTML site to be converted to a WordPress site with the same theme.
I've added the 'wp_enqueue_style' to the functions.php file for WordPress to find the CSS file but still it's not working.
functions.php
<?php
function our_theme_dependencies(){ ?>
<script>alert("its working"); </script>
<?php
//css libraries
wp_enqueue_style('main-style', get_stylesheet_directory_uri().'/assets/css/style.css');
wp_enqueue_style('bootstrap-style', get_stylesheet_directory_uri().'/assets/css/jquery.bxslider.css');
wp_enqueue_style('plugin-set', get_stylesheet_directory_uri().'/assets/css/plugin.css');
}
add_action('wp_enqueue_scripts', 'our_theme_dependencies');
?>
front-page.php
<?php get_header(); ?>
<div class="notice-board-row">
<div class="container notice-board-container">
<div class="notice-board-wraper">
<h3>Notice Board</h3>
<div class="notice-board-slider">
<div class="notice-item">
<div class="date">
<span class="month">Jan</span>
<span class="no">22</span>
<span class="year">2020</span>
</div>
<?php get_footer(); ?>
I am expecting the same theme as in the HTML version of the site to be converted to WordPress site.
converted html page to wordpress
css is not working

Order posts latest on top php sql

I want my latest post to be on top of other posts, how can i accomplish this? Now it just posts the latest at the bottom of the one i posted before.
I use this simple code to display my posts:
<div class="container">
<?php foreach ($articles as $article) { ?>
<div class="box">
<div class="boximg"> </div>
<div class="z link">
<a href="article.php?id=<?php echo $article['article_id'] ; ?>">
<?php echo $article['article_title']; ?>
</a>-
<small> posted
<?php echo date('l jS', $article['article_timestamp']); ?>
</small>
</div>
</div>
<?php } ?>
<br>
</div>
Can someone help me with this please?
Try fetching the articles like this:
SELECT *
FROM articles
ORDER BY article_timestamp DESC;
See MySQL ORDER BY: Sort a Result Set for insight.

Bootstrap 4 Reponsive Line Breaks

I'm not finding anything in the documentatin to point me in the right direction here and I'm trying to avoid using columns since that could leave gaps between the wording.
I'm displaying the days date on the top of my site using echo date('l') . "<br>" . date('F d, Y');. Which displays the date like this but centered:
Friday
November 03, 2017
On small screens such as phones I'd like for it to display as Friday November 03, 2017 without the line break.
I know I could easily just do this and achieve it but it creates gaps between the words since the columns are even in size:
<div class="row">
<div class="col-sm-6 col-md-12">
<?php echo date('l'); ?>
</div>
<div class="col-sm-6 col-md-12">
<?php echo date('F d, Y'); ?>
</div>
Are there any other ways to achieve this?
What I mean by gap is Friday [gap here due to column space] November 03, 2017.
I never see this question, but, my sugestion is this:
between dates, you can set a div clearfix, this div is only md size, so you make a hidden-sm and hidden-xs class like:
<div class="row">
<div class="col-sm-6 col-md-12">
<?php echo date('l'); ?>
<div class="clearfix hidden-xs hidden-sm"> </div>
<?php echo date('F d, Y'); ?>
</div>
</div>
it's correct? the clearfix div separate dates only on lg and md sizes.
The more straightforward option is to use the display classes built-in to Bootstrap and hide the <br /> based on screen size.
echo date('l') . "<br class='d-md-none' />" . date('F d, Y');
The use of columns or wrapping content in spans is overkill; just throw in a little display class and show/hide as needed.
Here is a solution for your question
<div class="row">
<div class="col-md-6 col-sm-12">
<div class="row">
<?php echo date('l'); ?>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="row">
<?php echo date('F d, Y'); ?>
</div>
</div>