WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Showing two ctageories on one page? (10 posts)

  1. Infexious
    Member
    Posted 3 years ago #

    http://www.infexious.tv/word/mixes/

    I am trying to make this show two lists of mixes posts with different categories but i am finding the second list is aligned to the right and is also adding everything in the list above.

    here is the code... any suggestions on how to fix this?

    <strong>Hardstyle Mixes</strong>
    
    [catlist=48]
    <br />
    
    <strong>Harddance and Hardtrance Mixes</strong>
    
    [catlist=49]
    <br />
  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    can you provide more information?

    can you post the full code of the [catlist=..] shortcode?
    is that from a plugin?
    if so, plugin download link?

    the shift to the right comes from the fact that the shortcodes don't seem to close the <ul> tags they open.

  3. Infexious
    Member
    Posted 3 years ago #

    this is the category plug-in we are using..

    http://pixline.net/wordpress-plugins/category-page-wordpress-plugin/en/

    we reset and closed uls - it fixed the alignment problem, but is still confusing what should be in each category by putting top category items also in the catgory below it on the page.

    The bottom four mixes in 2nd cat should be in 2nd list only and the rest in 1st list only!

    <strong>Hardstyle Mixes</strong>
    
    [catlist=48]
    </ul>
    <strong>Harddance and Hardtrance Mixes</strong>
    
    [catlist=49]
    <br />
    
    </ul>
  4. Infexious
    Member
    Posted 3 years ago #

    anyone? ;-)

  5. Infexious
    Member
    Posted 3 years ago #

    can you post the full code of the [catlist=..] shortcode?
    is that from a plugin?
    if so, plugin download link?

    where do i get this from?

  6. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    never mind - i downloaded the code.
    the plugin is definitively broken - missing closing ul and double post list.
    it is caused by not resetting a variable within the code.

    changing the code from about line 604 of page2cat.php to the code below might work for your purpose:

    // filter the content of a page, check for tag and replace it with a list of posts in the requested category.
    // function heavily inspired from Alex Rabe NextGen Gallery's nggfunctions.php.
    function page2cat_content_catlist($content){
    global $post;
    	if ( stristr( $content, '[catlist' )) {
    		$search = "@(?:<p>)*\s*\[catlist\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
    		if	(preg_match_all($search, $content, $matches)) {
    			if (is_array($matches)) {
    				$title = get_option('p2c_catlist_title');
    				if($title != "") $output = "<h4>".$title."</h4>"; else $output = "";
    
    				$limit = get_option('p2c_catlist_limit');
    				foreach ($matches[1] as $key =>$v0) {
    				$output .= "<ul class='p2c_catlist'>";
    					$catposts = get_posts('cat='.$v0.'&numberposts='.$limit);
    						foreach($catposts as $single):
    						$output .= "<li><a href='".get_permalink($single->ID)."'>".$single->post_title."</a></li>";
    						endforeach;
    					$search = $matches[0][$key];
    					$replace= $output.'</ul>';
    					$output='';
    					$content= str_replace ($search, $replace, $content);
    				}
    
    			}
    		}
    	}
    return $content;
    }

    worked in my local test setup with two different categories.

    no more need to add the </ul> yourself.

  7. Infexious
    Member
    Posted 3 years ago #

    Thanks mate. Just downloading the whole installation so i can find page2cat.php . Will let you know how i get on.

  8. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    page2cat.php is in the wp-contents/plugins/page2cat folder.

  9. Infexious
    Member
    Posted 3 years ago #

    tried it but i got this error when i try n load the mixes page

    Parse error: syntax error, unexpected T_STRING in /home/twistedm/infexious.tv/word/wp-content/plugins/page2cat/page2cat.php on line 632

  10. Infexious
    Member
    Posted 3 years ago #

    I TRIED AGIN AND IT WORKS! not sure why nto before
    thanks loads!

Topic Closed

This topic has been closed to new replies.

About this Topic