• Resolved Eberth Manuel Torres

    (@eberthtorres)


    Hello,

    configure the plugin in a theme made by me, at the end of the post I made a query to show more post with related tags.

    That query does not work in post duplicates.

    This is my code:

    
    $post_tag = get_the_tags ( $post->ID );
    $id = get_the_id();
    // Define an empty array
    $ids = array();
    // Check if the post has any tags
    if ( $post_tag ) {
        foreach ( $post_tag as $tag ) {
            $ids[] = $tag->term_id; 
        }
    }
    // Now pass the IDs to tag__in
    $relatedargs = array(
    	'showposts'		=> '5',
    	'post__not_in'	=> array($id),
        'tag__in'  	 	=> $ids,
    );
    // Now proceed with the rest of your query
    $relatedposts = new WP_Query( $relatedargs );
    
    while( $relatedposts->have_posts() ) : $relatedposts->the_post();
    
    // the loop
    
    endwhile; wp_reset_postdata();
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    Hi @eberthtorres

    Thank you for your enquiry.

    The plugin has action hooks that you can use for the repeater template should you wish to add additional content. I recommend giving them ago.

    See documentation on action hooks. https://autoloadnextpost.com/documentation/action-hooks/

    Hope that helps.

    regards,

    Sébastien.

    Thread Starter Eberth Manuel Torres

    (@eberthtorres)

    i have a function that change original wordpress gallery

    
    add_shortcode( 'gallery', 'modified_gallery_shortcode' );
    	
    	function modified_gallery_shortcode($attr) {
        if(!empty($attr["normal"]) && $attr["normal"] == "true"){
    	    $output = gallery_shortcode($attr);
        } else {
    	    
    	    $image_ids = explode(',', $attr['ids']);
    	
    	    $output = '';
    	    $size = 'destacada'; // Forzar un tamano
    	
    	    foreach($image_ids as $attachment_id) {
    			$img_src = esc_url(  wp_get_attachment_image_url( $attachment_id, $size ) );
    			$img_src_owl = esc_url(  wp_get_attachment_image_url( $attachment_id, 'full' ) );
    			
    	        $img_srcset = esc_attr( wp_get_attachment_image_srcset( $attachment_id, $size ) );
    	
    	        $alt = esc_attr ( get_post_meta($attachment_id, '_wp_attachment_image_alt', true) );
    	        $link = esc_attr ( get_post_meta($attachment_id, '_gallery_link_url', true) );
    	        $the_attachment = get_post($attachment_id); // post
    	        $caption = esc_attr ( $the_attachment->post_excerpt );
    	
    	        $img = "<img src='" . $img_src . "' srcset='" . $img_srcset . "' sizes='" . auto . "' alt='" . $alt . "'>";
    	        $link = "<a href='" . $img_src_owl . "' class='galeria'>" . $img . "</a>";
    	        $caption = "<figcaption>" . $caption . "</figcaption>";
    	        $item = "<div class='item news-post image-post3'>" . $link . $caption . "</div>";
    	
    	        $output .= $item;
    	    }
    	    $output = 
    	    '<div class="carousel-box owl-wrapper gallery-post">'.			
    			'<div class="title-section"><h3><span>Galería</span></h3></div>'.
    			'<div class="owl-carousel" data-num="3">'.
    				$output .
    			'</div>'.
    		'</div>' ;
    	    }
        return $output;
        }
    

    That does not work too, any idea?

    Plugin Author Sébastien Dumont

    (@sebd86)

    As far as I know, the default WordPress gallery shortcode works fine with ALNP.

    Thread Starter Eberth Manuel Torres

    (@eberthtorres)

    The problem was the owl js function

    I solved this by using the “after a post has loaded” trigger

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query inside post duplicated not working’ is closed to new replies.