Hi, you can disable gallery loading by adding the code below in your theme functions.php file
add_action( "init", "my_init", 1000 );
function my_init() {
remove_action('adverts_tpl_single_top', 'adverts_single_rslides');
}
then you can display the gallery somewhere else by using the
adverts_single_rslides( $post_id );
function.
Hi,
I’ve created file single-advert.php and put it in the root of the WP theme. Than moved needed content from wpadverts/templates/single.php. Everything was done as indicated in the documentation https://wpadverts.com/documentation/child-themes-and-templates/.
Below is the code:
<?php get_header();?>
<?php
wp_enqueue_style( 'adverts-frontend' );
wp_enqueue_style( 'adverts-icons' );
wp_enqueue_style( 'adverts-icons-animate' );
wp_enqueue_script( 'adverts-frontend' );
?>
<div class="container template_block">
<div class="row">
<div class="car post_content">
<h1 class="title"><?php the_title(); ?></h1>
<?php do_action( "adverts_tpl_single_top", $post_id ) ?>
<div class="adverts-single-box">
<div class="adverts-single-price">
<span class="adverts-price-box">
<?php echo esc_html( adverts_get_the_price( $post_id ) ) ?>
</span>
</div>
</div>
<div class="adverts-grid adverts-grid-closed-top adverts-grid-with-icons adverts-single-grid-details">
<?php $advert_category = get_the_terms( $post_id, 'advert_category' ) ?>
<?php if(!empty($advert_category)): ?>
<div class="adverts-grid-row ">
<div class="adverts-grid-col adverts-col-30">
<span class="adverts-round-icon adverts-icon-tags"></span>
<span class="adverts-row-title">test</span>
</div>
<div class="adverts-grid-col adverts-col-65">
<?php foreach($advert_category as $c): ?>
<?php echo join( " / ", advert_category_path( $c ) ) ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if(get_post_meta( $post_id, "adverts_location", true )): ?>
<div class="adverts-grid-row">
<div class="adverts-grid-col adverts-col-30">
<span class="adverts-round-icon adverts-icon-location"></span>
<span class="adverts-row-title"><?php _e("Location", "adverts") ?></span>
</div>
<div class="adverts-grid-col adverts-col-65">
<?php echo apply_filters( "adverts_tpl_single_location", esc_html( get_post_meta( $post_id, "adverts_location", true ) ), $post_id ) ?>
</div>
</div>
<?php endif; ?>
<?php do_action( "adverts_tpl_single_details", $post_id ) ?>
</div>
<div class="adverts-content">
<?=apply_filters('the_content',$post->post_content)?>
</div>
</div>
</div>
</div>
<?php get_footer();?>
But in the end, I have a gallery with all the images on the page as above. And the location is not displayed.
Just tried to replace the line
<? php do_action ("adverts_tpl_single_top", $ post_id)?>
on
<? php echo esc_html (adverts_single_rslides ($ post_id))?>
as you suggested above
The result is the same – the gallery displays all the pictures
Would you be so kind as to help to solve the problem?
How can I display pictures in the gallery that are only related to current ad?
-
This reply was modified 7 years, 7 months ago by
densky.
-
This reply was modified 7 years, 7 months ago by
densky.
-
This reply was modified 7 years, 7 months ago by
densky.
-
This reply was modified 7 years, 7 months ago by
densky.
Hi,
please note that to the single-advert.php you should copy the code from single.php or page.php file in your current child-theme or theme directory, NOT from wpadverts/templates/single.php.
The way you have it setup right now most likely is causing a fatal error so the location and other parts of Ad details do not display.
Thank you very much for your help.
I was in the theme was not a working file single.pxp
But I found a solution on the Internet
So now the working version of the single-advert.php file looks like:
<?php get_header();?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_footer();?>