ACF Repeater displays correct when logged in but empty for guest - advanced-custom-fields

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; ?>

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

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

Links configured in the template administration panel don't work on the website

The problem on a Wordpress site is that even though links are set properly in the WP admin area (see attachment 1) they do not work once the site has been published. When using inspect element it kind of shows the problem (see attachment 2).
Clicking and opening the links within the admin area is working just fine. Other links on the website work correctly. What is missing here?
Code in WP template:
<?php if ($section['link_to_doc']) : ?>
<?php foreach ($section['link_to_doc'] as $link) : ?>
<div>
<a href="<?php echo $link['link_to_doc'] ?>" class="btn-txt">
<?php echo $link['text_of_link'] ?>
</a>
</div>
<?php endforeach; ?>
<?php endif; ?>
Repeater fields:
It seems the ACF link object is not returning the right output in the href because of an error in how the links where coded.
Usually you'll want something like this:
$link = get_field('link');
<a href="<?= $link['url']) ?>"<?= $link['title'] ?></a>
That's providing the ACF field is not nested, and the field name is 'link' and there's just one.
Amended code (presumably):
<?php if ($section['link_to_doc']) : ?>
<?php foreach ($section['link_to_doc'] as $link) : ?>
<div>
<a href="<?= $link['url'] ?>" class="btn-txt">
<?= $link['text_of_link'] ?>
</a>
</div>
<?php endforeach; ?>
<?php endif; ?>
Even thought the whole concept is not the best, as you wouldn't create an extra custom field to put the text of the link since you can use $link['title'] for that but yeah...
Edit 2:
According to your screenshot edit the a to be:
<a href="<?= $link['link'] ?>" class="btn-txt">
<?= $link['text_of_link'] ?>
</a>

Wordpress - How to get the most viewed posts?

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

When Logged out, one blog shows - logged in, all blogs show

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).