WordPress.org

Ready to get started?Download WordPress

Forums

Page2cat: Category, Pages & Posts Shortcodes
[resolved] shortcode posted always at top of page/post (3 posts)

  1. arodeus
    Member
    Posted 1 year ago #

    Hi,
    I experienced the following issue: posting a new article with PP short code, the output was always put on top of the pages. I solved the issue editing the shortcode code as following:

    NOTE: bolded text is the added code

    function showlist( $atts ){
        	extract( shortcode_atts( array(
        		'catid' => '',
        		'lenght' => '10',
        		'listclass' => 'aptools-list',
        		'header' => '2',
        		'headerclass' => 'aptools-list-header',
        		'excerpt' => 'false',
        		'image' => 'false',
        		'wrapper' => 'false',
        		'wrapperclass' => 'aptools-list-wrapper'
        	), $atts ) );
    
            $hopen = '<h'.$header.' class='.$headerclass.'>';
            $hclose = '</h'.$header.'>';
    
            if( $catid !== '' ):
                $args = array( 'category__in' => array($catid), 'posts_per_page' => $lenght );
            endif;
    
            $page = new WP_Query( $args );
    	<strong>ob_start();</strong>
            if( $page->have_posts() ):
                if( $wrapper !== 'false'){
                    echo '<div class="'.$wrapperclass.'">';
                }
                echo '<ul class="'.$listclass.'">';
                while( $page->have_posts() ):
                    $page->the_post();
                    echo '<li>';
                    echo '<a href="'.get_permalink().'">'.get_the_title().'</a>';
                    if( $image !== 'false' && has_post_thumbnail() ){ the_post_thumbnail( $image ); }
                    if( $excerpt === 'true' ) echo ' <span>'.get_the_excerpt().'</span>';
                    echo '</li>';
                endwhile;
                echo '</ul>';
                if( $wrapper !== 'false'){
                    echo '</div>';
                }
            endif;
    	<strong>$content = ob_get_clean();</strong>
            wp_reset_postdata();
    	<strong>return $content;</strong>
        }

    http://wordpress.org/extend/plugins/page2cat/

  2. lightworkerarts
    Member
    Posted 1 year ago #

    Hi!

    I have the same issue.

    Is there any plan to update the shortcode so that it will display at the insertion point in the page/post?

  3. swergroup
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you for caring: the issue should be resolved in the next upgrade alongside other issues.

    If you're willing to try a beta version (please, not on production sites) here's our development repo:

    http://dev.swergroup.com/pages-and-posts-shortcodes/

    beta testers and bug reporters needed!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic