Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a problem with the loop running on two instances with thecartpress plugin. Im not great with php by any standards but can usually get things done, however with wordpress im fairly new. Is there a way to have my plugin control the loop for just my catalog page and have wordpress ignore it? i hope im not being to vague.

THIS IS ALL CODE FROM PAGE.PHP IN MY THEME

        <?php 
            global $projectTheme;

            get_header();

        ?>


        <?php get_template_part('theloop'); ?>

        <?php comments_template(); ?>

        <?php get_template_part('navigation'); ?>

                    <?php get_footer(); ?>

THIS IS THE ONLY HTML ON THE CATALOG PAGE CREATING THE DUPLICATION

                  [tcp_list id="all_products"]

That is shortcode from the tcp (thecartpress plugin) Now this plugin is great, it gives you options for theme compatibility, asking how to display things in your catalog, and whether to let your theme control the loop, or use their configurable loop, however i have exhausted every bit on settings within their control panel and none of their settings effect this. I believe anymore its something with their shortcode, which is done by using a shortcode generator they supply with the plugin. I feel as though my theme runs this shortcode, and their plugin as well no matter how i set it, causing a double loop?

share|improve this question
2  
Are you looking to control the HTML output of the loop on a particular page? How exactly is the output for the page being generated? Is it via a custom template you're providing, or is it handled by the theme? –  Andy Adams Dec 20 '12 at 23:11
    
take a look here please dtowndiscgolf.com/wp/?page_id=96 you'll see the page "Catalogue" is repeating its posts twice.. so id like it to only display once, but i feel as if ,y theme and thecartpress plugin are each fighting for attention, but i just cant figure out where. the HTML output doesnt show anything funny going on, other then the repetition –  theProject Dec 21 '12 at 0:52
    
Thanks for the link! Now, could you paste 2 things in your question: 1. The PHP code for the page.php template in your theme, and 2. The HTML content (from the WordPress editor on the Edit Page screen) from the page in question? That will help us figure out what is going on. Thanks! –  Andy Adams Dec 21 '12 at 19:08
    
thanks andy, i really appreciate it, ill post it now! –  theProject Dec 22 '12 at 5:38
    
Hey again, I have one more question - when you remove the shortcode from the HTML content, are both loops removed, or does one remain on the page? Basically, is the shortcode itself generating the 2 loops, or is it generating only 1 in addition to the "regular" loop? –  Andy Adams Dec 26 '12 at 18:35
show 1 more comment

1 Answer 1

up vote 0 down vote accepted

The problem was in my the loop.php file, i was executing a new loop using the wordpress parameters for the main loop, which caused a duplication with the plugin being used (thecartpress) which executes its own loop. I was using:

       global $post, $query_string, $discTheme;
       query_posts($query_string);

in a sense, with thecartpresses own loop, I was duplicating the loop for this page.

With the bright eyes of my friend the sensei, a simple removal of:

       query_posts($query_string);

fixed my duplication issue.

Hope this makes sense and helps anyone else out there.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.