• Hi, I have just installed and created shortcode [related_posts] when i put this in editor it just returns [related_posts]

    snippet code below, Anything i’m missing? Thanks!

    `<?php
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
    echo ‘<h2>Related Articles</h2>’;
    $first_tag = $tags[0]->term_id;
    $args=array(
    ‘tag__in’ => array($first_tag),
    ‘post__not_in’ => array($post->ID),
    ‘posts_per_page’=>3,
    ‘caller_get_posts’=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post();
    ?>
    ” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?>
    <p class=”single-cat-date”><?php the_category();?> <?php echo get_the_date(); ?></p>
    <?php echo do_shortcode(‘[rt_reading_time label=”” postfix=”MIN <span>READ</span>” postfix_singular=”MIN <span>READ</span>” post_id=”‘ . $post->ID . ‘”]’)?>
    <?php
    endwhile;
    }
    wp_reset_query();
    }
    ?>’

    The page I need help with: [log in to see the link]

Viewing 12 replies - 16 through 27 (of 27 total)
  • Thread Starter jfkweb

    (@jfkweb)

    Thread Starter jfkweb

    (@jfkweb)

    Plugin Support Temyk

    (@webtemyk)

    In your column “Where Use?” standard shortcode. Have you saved a snippet with new settings?
    Try creating a new snippet with the same settings

    Thread Starter jfkweb

    (@jfkweb)

    dont understand.you mean the custom shortcode is not appearing in where use?

    I think its a problem with the code. putting the_date() works

    Plugin Support Temyk

    (@webtemyk)

    Shortcode should work regardless of errors in the code.

    Here is your working code:

    global $post;
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
    	echo '<h2>Related Articles</h2>';
    	$first_tag = $tags[0]->term_id;
    	$args=array(
    		'tag__in' => array($first_tag),
    		'post__not_in' => array($post->ID),
    		'posts_per_page'=>3,
    		'caller_get_posts'=>1
    	);
    	$my_query = new WP_Query($args);
    	if( $my_query->have_posts() ) {
    		while ($my_query->have_posts()) : $my_query->the_post();
    			?>
    			" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
    			<p class="single-cat-date"><?php the_category();?> <?php echo get_the_date(); ?></p>
    			<?php echo do_shortcode('[rt_reading_time label="" postfix="MIN <span>READ</span>" postfix_singular="MIN <span>READ</span>" post_id="' . $post->ID . '"]');
    		endwhile;
    	}
    	wp_reset_query();
    }
    Thread Starter jfkweb

    (@jfkweb)

    actually date doesnt work. https://imgur.com/IW4cV7f

    Thread Starter jfkweb

    (@jfkweb)

    Thread Starter jfkweb

    (@jfkweb)

    there are bits missing from that – did you edit?

    Thread Starter jfkweb

    (@jfkweb)

    thats working! was it the print_r($tags) line? you commented it out.

    Thread Starter jfkweb

    (@jfkweb)

    thank you!

    Plugin Support Temyk

    (@webtemyk)

    Commented code can be removed. Is your problem solved? Is the shortcode name working?
    If not, check if you have a separate premium Woody plugin installed.

    Thread Starter jfkweb

    (@jfkweb)

    thanks, yes working but inly in noirmal editore, trying to get it workin g in divi builder. I’m on to them also. thanks for your help!

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘Shortcode not working’ is closed to new replies.