I have created ACF Fields for Wordpress User page Text and image When I try to display on single.php its not showing nither image or text is showing below is screenshot for refrence.
https://prnt.sc/ezFU-JPZH3Rs
<ul class="list-unstyled">
<li>
<div class="row">
<div class="col-4">
<div class="home-blog-author">
<?php
$avatar_image= get_field('user_image', 'user_'. $author_id );
?>
<picture>
<img src="<?php echo $avatar_image['url']; ?>" class="img-fluid" alt="<?php echo $avatar_image['alt']; ?>">
</picture>
</div>
</div>
<div class="col-8 align-self-center ps-0">
<div class="home-author-name">
<h5><?php //echo the_field('user_name', 'user_' .$author_id); ?></h5>
</div>
</div>
</div>
</li>
<li>
<i class="fas fa-calendar-alt"></i>
<span><?php echo get_the_date('d/m/Y'); ?></span>
</li>
</ul>
You know that in your snippet you have the name text commented out, right? Otherwise you have multiple possible failure points. Off the top of my head:
Are you sure you're retuning the html as expected (with or without the ACF data)? If not, then you may have the wrong template or other problems. If so:
Are you sure you have the ACF user_image field set to return an array - and in particular for the user you're testing?
Have you tried returning the ACF field by key rather than field name? That sometimes helps.
Related
I´m making a site for myself and I´ve been stuck with this issue. The site has several categories, for example geometry -> triangles. When I'm scrolling through articles and do not have a filtered category on yet, everything is ok. But when I filter categories and choose a specific one, for example triangles, all other articles that do not concern triangles get hidden. But that's not the issue. The problem is, if the articles for triangles where on the page 3 while the filter was off and you could see all the articles all together, then even after the filter is on the chosen category will be left on the page 3 and won't move to the first page. How do I fix this?
bodyOfmainPage.php
<main class="index-main">
<section class="articles">
<div class="article_content container container--pall">
<h1 class="heading">მთავარი გვერდი</h1>
<div class="article_grid">
<?php $idM=get_size(); ?>// number of articles
<?php for($id=$idM;$id>0;$id--): ?>
<?php $idN= get_num_size($id);?>
<div class="article_item" href="#" data-id ="<?= intval(($idM - $id)/4 + 1) ?>" data-category="<?= get_data_category($id) ?>">
<div class="article_image" style="background-image: url('<?= get_img_url($id) ?>')"> </div>
<div class="article-text">
<div class="article_date"><?= get_article_date($id) ?></div>
<div class="article_title"><?= get_article_title($id) ?></div>
<div class="article_description"><?= get_article_description($id) ?></div>
<div class="hashtag"><?= get_hashtag($id) ?></div>
<div class="butt">
<a class="AB" href="<?= get_article_link($id) ?>">
<button type="button" class="clickA" >გადასვლა</button></a>
</div>
</div>
</div>
<?php endfor; ?>
</div>
</div>
</section>
<div class="num">
<ul class="contentNum">
<li class="navigation" data-id ="1">1</li>
<li class="navigation" data-id ="2">2</li>
<li class="navigation" data-id ="3">3</li>
<li class="navigation" data-id ="4">4</li>
<li class="navigation" data-id ="5">5</li>
</ul>
</div>
</main>
Just wondering, I'm creating a multi-vendor website. So far it has all been going well, however we have a need to display icons as badges if a field contains data.
Here is an example of the code:
<li class="location clearfix">
<div class="pull-left">
<span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span>
</div>
<div class="pull-right">
<?php echo $abn; ?>
</div>
</li>
When displaying the field abn it appears fine, although we are wanting an icon displayed if abn contains data. We are needing the Echo to be an IF statement, that if the profile ``abn``` field contains data, that an icon is displayed.
Just wondering, is there any examples that anyone would have using an existing script?
Thanks for helping!
Try this,
add if condition with !empty()
<?php if(!empty($abn)) {?>
<li class="location clearfix">
<div class="pull-left">
<span><i class="fa fa-briefcase"></i><?php _e('abn ',) ?></span>
</div>
<div class="pull-right">
<?php echo $abn; ?>
</div>
</li>
<?php } ?>
you can add this if condition wherever you want to hide or display data.
I've almost finished my first custom theme for a website. I've created some custom post type to manage a portfolio and a staff member section. No problem with the code, but the client asked if is it possible to change the staff images when an user hover on it. Is there any way to achieve this in wordpress?
Here is a sample of my code
<div class="team-boxed">
<?php
$args = array(
'post_type' => 'team'
);
$team = new WP_Query($args);
?>
<div class="intro">
<h2 class="text-center text-uppercase" id="">Team</h2>
</div>
<div class="row people">
<?php if( $team->have_posts() ): while( $team->have_posts() ): $team->the_post(); ?>
<div class="col-md-6 col-lg-4 item">
<div class="box">
<div class="rounded-circle" style="background-image:url('<?php the_post_thumbnail_url('full'); ?>')" id="staff-pic"></div>
<h3 class="team-name"><?php the_title(); ?></h3>
<p class="description text-center"><?php echo get_the_content(); ?></p>
<div class="social"><i class="fab fa-facebook"></i><i class="fab fa-twitter"></i><i class="fab fa-instagram"></i></div>
</div>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
</div>
Simplest way would be to output that like this. If you have ALT image stored in custom meta for example you can use that as SECOND IMAGE.
<img src="FIRST IMAGE" onmouseover="this.src='SECOND IMAGE'" onmouseout="this.src='FIRST IMAGE'" />
Other options include outputting some additional CSS or JS. But you can also use general JS with data attributes maybe to handle that with more options, animations etc.
I have an Ajax call loading more posts onto a page. Everything works and I get the HTML back from the template that I have but it's missing all the of post information so it's just the html skeleton.
I'm using the same template to load the first posts onto the page but then when using the ajax call, I can't get the Wordpress methods to display back the data.
When I var dump on my template php file, I can see all of the post information but it doesn't come through back to the inline php.
Loading the Posts:
foreach (load_posts($offset) as $post) {
include(locate_template('_includes/loop-archive-single.php'));
}
The Template:
<li>
<div class="card">
<div class="card__bd">
<div class="feature">
<div class="feature__media">
<a class="imgLink" href="<?php the_permalink(); ?>">
<img src="<?php the_field('media_image') ?>" alt="<?php the_field('media_image') ?>" />
</a>
</div>
<div class="feature__hd">
<h2 class="hdg hdg--lg">
<?php the_title(); ?>
</h2>
</div>
<div class="feature__bd">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
</li>
Am I outside the loop or what's going on? I'd like to keep the template that way it is right now. Again, the post data is there, but it just won't show through the_permalink() or the_field('media_image') and anything like that...
You will have to pass the ID on ajax call ... of which post you need
change the template file to
<li>
<div class="card">
<div class="card__bd">
<div class="feature">
<div class="feature__media">
<a class="imgLink" href="<?php the_permalink(); ?>">
<img src="<?php the_field('media_image',$post_ID) ?>" alt="<?php the_field('media_image',$postID) ?>" />
</a>
</div>
<div class="feature__hd">
<h2 class="hdg hdg--lg">
<?php the_title(); ?>
</h2>
</div>
<div class="feature__bd">
<?php the_excerpt($postID); ?>
</div>
</div>
</div>
</div>
</li>
i am new to wordress
i want to make image gallery from basic bootstrap template
i have this template for example:
<div class="row portfolio-images">
<div class="col-md-3">
<img src="">
<a class="title" >title</a>
</div>
<div class="col-md-3">
<img src="" alt="">
<a class="title" >title</a>
</div>
<div class="col-md-3">
<img src="" alt="">
<a class="title" >title</a>
</div>
<div class="col-md-3">
<img src="" alt="">
<a class="title" >title</a>
</div>
</div>
i want to know how to create image database or gallery in wordpress in the panel
and get the images url in an array and do something like this:
<div class="row portfolio-images">
<?php
for(the array){ ?>
<div class="col-md-3">
<img src="<?php echo image url ?> ">
<a class="title" ><?php echo image title ?></a>
</div>
<?php }?>
</div>
because im lost right now and i need some guidence
There are various plugins that you can use to generate the gallery. If you need to generate one without plugin then you can define a custom post type and then add images post on the relevant post type, which then can be listed on the required page.
Usually I use ACF plugin to generate custom field and then list it on the page. You can check it more here: http://www.advancedcustomfields.com/resources/gallery/