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
Related
I have an ACF repeater setup to show a bunch of images with links. Works perfectly when logged in, but when viewing the same page as a guest it shows empty html without the urls for images/links e.g:
<a href="β target=βblankβ>
<img src="β width=β260β³ height=β130β³>
I am using PHP widget plugin, embedded in an elementor page section. ACF code is added to php widget (don't usually have problems with this method)
Code below, as mentioned works perfectly for a logged in user, but when logged out all you see is "<a href="β target=βblankβ>
<img src="β width=β260β³ height=β130β³>"
```` <div id="supplier-container">
````<?php while (have_rows('suppliers')): the_row(); ?>
```` <div class="supplier-single">
````<?php if (get_sub_field('supplier_link')): ?>
```` <a href="<?=get_sub_field('supplier_link')?>" target="blank">
````<?php endif; ?>
```` <div class="image-container">
```` <img src="<?=get_sub_field('supplier_image')?>" width="260" height="130">
```` </div>
```` </a>
````<?php endif; ?>
```` </div>
````<?php endwhile; ?>
```` </div>
````<?php endif; ?>
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.
Good day all, I hope everybody is well.
I am having some troubles executing Foundation 5 Tabs to my site.
I came cross this: http://foundation.zurb.com/forum/posts/856-foundation-5-tab-issues and found similar output, just that mine are not working.
It seems that something blocked my script. I tried to moved it to my header.php, different parts of footer.php, and single.php, but no luck.
Images of output can be seen at the bottom.
Hope someone can help me out with this.
<?php /* single.php */ ?>
<?php get_header(); ?>
<body>
<section class="common-title-wrap">
<div class="row"><h2><?php single_post_title(); ?></h2></div>
</section>
<section class="common-section">
<div class="single-column">
<div class="side-nav">
<?php
$options = array(
'sort_column' => 'menu_order',
'menu' => 'Equipment Menu',
'container' => false
);
wp_nav_menu($options); ?>
</div>
<div class="tab-column">
<ul class="tabs" data-tab role="tablist">
<li class="tab-title active" role="presentation">Equipment</li>
<li class="tab-title" role="presentation">Equipment Rental</li>
<li class="tab-title" role="presentation">Equipment Purchase</li>
<li class="tab-title" role="presentation"><a href="#panel2-4" role="tab" tabindex="0" aria-selected="false" aria-controls="panel2-4">Video<a></li>
</ul>
<div class="tabs-content">
<section role="tabpanel" aria-hidden="false" class="content active" id="panel2-1">
<p><?php echo the_field('equipment'); ?></p>
</section>
<section role="tabpanel" aria-hidden="true" class="content" id="panel2-2">
<p><?php echo the_field('equipment_rental'); ?></p>
</section>
<section role="tabpanel" aria-hidden="true" class="content" id="panel2-3">
<p><?php echo the_field('equipment_purchase'); ?></p>
</section>
<section role="tabpanel" aria-hidden="true" class="content" id="panel2-4">
<p><?php echo the_field('equipment_video'); ?></p>
</section>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
<?php /* Template Name: Footer */ ?>
<footer>
<div class="site-footer">
<div class="copyright">
<p>Copyright Β©. All Rights Reserved.</p>
</div>
</div>
</footer>
<?php wp_footer();?>
<script src="/js/vendor/jquery.js"></script>
<script src="/js/foundation.min.js"></script>
<script src="/js/foundation/foundation.tab.js"></script>
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<script>
$(document).foundation();
</script>
</body>
</html>
Your script locations aren't pointing correctly. When you run scripts using that format "/js/something.js", you're telling the server to go to the root folder, find the 'js' folder and then run the file you've specified. With your WordPress install, this is in domain.com/js/something.js, not in wordpress.com/wp-content/themes/theme-name/js/something.js where everything is referenced through.
You need to do 1 of 3 things:
Move your JS files to the actual root of the domain in a folder called 'JS'. I don't really recommend this solution as you're then separating your JS from your theme and adding files to the root, but this would fix your problem easily.
Use the built-in WP functions like get_template_directory(), get_stylesheet_directory(), and other similar functions. With these, you can make your paths look like <script src="<?php get_theme_directory(); ?>/js/vendor/jquery.js"></script> and it'll point to the right spot. Look at the WP documentation and find the one appropriate for your situation.
Use the wp_enqueue_scripts() functions and features to load your scripts. This is the best way to do this and is the way you should be handling this. The benefit of this method is that WP will watch for scripts so none of them load multiple times (unnecessarily) and it'll ensure that dependencies for scripts are met (foundation.js loads after jquery.js and any plugin JS, etc.). This is the most difficult method, but it's not really that hard and you really have to know how to do this if you're going to be developing WP themes.
Good luck!
How can I display my most viewed posts on a single page ?
For this moment, i've create a new template page (content-most-viewed.php) wich is called by get_template_part();
On Internet, i've read that query_posts could solve my problem, but it seems to fail.
This is my template :
<?php query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC');
//query_posts('post_type=post&posts_per_page=10&orderby=comment_count&order=DESC');?>
<div class="post">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="heading">
<h2><?php the_title();?></h2>
</div>
<?php the_content();?>
<div class="link-holder">Retour</div>
<?php endwhile; ?>
<?php else : ?>
<div class="heading">
<h2>Not Found</h2>
</div>
<p>Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
</div>
But, I can only get recent posts, or "Not Found" (any resutls)
In advance, thanks !
WordPress by itself does not keep track of the number a post is viewed there are pluging that do this: WPP, plugin repos
These plugins will have build in functions to do this.
side note
don't use query_posts its bad for preformance. use WP_query in stead. reasons why it is bad: https://wordpress.stackexchange.com/a/50762/10911, https://wordpress.stackexchange.com/a/50762/10911
I've coded this Wordpress site but I'm finding difficulties with the blog area. Only one blog shows in the blog section but with I am logged in as an admin, I can see all the blogs on the page. I need it to show for everyone, whether they are logged in as a user or just a visitor to the website.
I have attempted to see if it was a wordpress issue by checking the 'Settings >> Reading' settings and they are set just fine, showing to be 10 posts per page.. It could be something wrong with the loop. I have the blog pulling from the index.php.
http://www.ilovepennycakes.com/category/blog/
Here is the direct link to the blog not showing in the feed.
http://www.ilovepennycakes.com/thanksgiving-thoughts/
The code is as follows:
<?php get_header(); ?>
<!-- Article Loop -->
<article>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="news-top"></div>
<div class="news">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-header">
<h1 class="meander"><?php the_title(); ?></h1>
<p class="likes m500"><?php comments_popup_link( '0', '1', '%' ); ?></p>
<div class="clear"></div>
</div><!--end post header-->
<!--div class="entry clear"-->
<div class="blog-content m500">
<?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail(); ?>
<?php the_content(); ?>
<?php wp_link_pages(); ?>
</div>
<!--/div--><!--end entry-->
<p class="date M500">Posted <?php the_time( 'j M Y' ); ?></p>
<p class="M500"><?php edit_post_link( __( 'Edit', 'pennycakes' ), '<span>', '</span>' ); ?></p>
<!--end post footer-->
</div><!--end post-->
</div>
<div class="news-bottom"></div>
<?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
</div><!--end navigation-->
<div class="navigation index">
<div class="alignleft"><?php next_posts_link( 'Older Entries' ); ?></div>
<div class="alignright"><?php previous_posts_link( 'Newer Entries' ); ?></div>
<?php else : ?>
<?php endif; ?>
</article>
<!-- //Article Loop -->
Any help will be appreciated.
Hmmm... are your posts still "Drafts" or published? If they are drafts, it is normal to be able to see them only if you are logged in, because a draft is not published so not supposed to be seen by any visitor. That's my guess. Otherwise, please give more info.
Ok, so I have the answer for you: index.php is not the file used to display http://www.ilovepennycakes.com/category/blog/. The file used for this type of archive display is "category.php". If there is no such file in your theme folder, add it (possibly duplicate index.php as you have programmed it or take it from a default example template).