WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Please help... cannot get the_xxx() functions to work properly (1 post)

  1. squeaker2
    Member
    Posted 3 years ago #

    Hi,
    I am very new to wordpress implementation, and I had this blog almost fully operational until i changed to php echo's to clean up my code. The site is live at Malayla. This will take you to the blog page, and you will see that my tags are being displayed above my headers. For some reason I cannot control where the "the_xxx" functions post anything, they want to manually do it before my echo statement. So, i used get_the_xxx for the headers and the content which works good, but if i use get_the_category or tags they will not return permalinks relative to other posts tagged or categorized accordingly. Also, when the tags DO before functional Pagination will not allow me to go to more pages. I fixed this with the isset GetSearch cat above (Thanks to ESMI... why will the same theory not apply to tags? I am so lost.. any help to get pagination to work properly and my tags/categories to only show up when we know they are at a single post page... ("p=") would be greatly greatly appreciated. Here is the full code. Thank you!

    P.s. Also, because I am new to this.. please feel free to critique my code and tell me if I am an idiot for having so many lines when there is a simpler way if there is. Thanks again.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head profile="http://gmpg.org/xfn/11">
    
    	<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
    
    	<meta name="author" content="Travis Hoglund" />
    	<meta name="copyright" content="2010 Luke Studios" />
    	<meta name="revisit-after" content="3 days" />
    	<meta name="language" content="english" />
    	<meta name="distribution" content="Global" />
    	<!-- In the Description you should use no more than 25 to 30 words consisting of between 160-180 characters .. This description shows up as the summary of your page when googled. -->
    	<meta name="description" content="Luke Studios - Minneapolis - St. Paul Commercial Photography Studio - Twin Cities Commercial Photographer" />
    	<!-- Keywords are very specific .. NO more than 15 to 20 words, and use things very specific to your particular site -->
    	<meta name="keywords" content="meta, metatags, meta tag, meta tags, submit, search engines, spiders, sites, submit site, search engine submit, website, submit website, add meta tags, find website, be found on internet, keywords, keyword" />
    	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    
    	<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    	<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
    
    	<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
    	<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    
        <?php
    		function curPageURL() {
    		 	$pageURL = 'http';
    			 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    			 $pageURL .= "://";
    			 if ($_SERVER["SERVER_PORT"] != "80") {
    			  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    			 } else {
    			  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    			 }
    			 return $pageURL;
    		}
    
    		$currentURL = curPageURL();
    		$mystring = 'weddings=true';
    		$lukeweddings = strrpos($currentURL, $mystring);
    		if ($lukeweddings == true) { // note: three equal signs
    			echo('<link rel="stylesheet" type="text/css" href="../../../../weddings/css/style.css" />');
    		}
    		else {
    			echo('<link rel="stylesheet" type="text/css" href="../../../../css/style.css" />');
    		}
    
    	?>
        <link rel="stylesheet" type="text/css" href="pagination.css" />
    
    	<script type="text/javascript" src="../../../../js/preloader.js"></script>
    	<script type="text/javascript" src="../../../../js/rollover.js"></script>
    	<script type="text/javascript" src="../../../../js/jquery-1.2.6.min.js"></script>
    	<script type="text/javascript" src="../../../../js/slideshow.js"></script>
    	<script type="text/javascript" src="js/functions.js"></script>
    
    	<?php wp_get_archives('type=monthly&format=link'); ?>
    
    	<?php //comments_popup_script(); // off by default ?>
    
    	<?php wp_head(); ?>
    
    </head>
    
    <body>
    
    <div class="container">
    
    <?php	if ($lukeweddings == true) { // note: three equal signs
    			include("../weddings/includes/headerblog.inc.php");
    		}
    		else include("includes/header.inc.php");
    ?>
    
    <div class="spacer15"></div>
    
    <div id="container">
    
            <?php if(strrpos($currentURL, 'searchCat=commercial-photography') == true){include('../codeInc/welcomeheadings/commercialphotography.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=event-photography') == true){include('../codeInc/welcomeheadings/eventphotography.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=people-portraiture') == true){include('../codeInc/welcomeheadings/people.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=adventures-travel') == true){include('../codeInc/welcomeheadings/adventures.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=senior-portraits') == true){include('../codeInc/welcomeheadings/senior.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=creative-artistic') == true){include('../codeInc/welcomeheadings/creative.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=wedding-photography') == true && strrpos($currentURL, 'weddings=true') == false){include('../codeInc/welcomeheadings/wedding.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=retouching-photoshop') == true){include('../codeInc/welcomeheadings/retouching.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=links-tools') == true){include('../codeInc/welcomeheadings/links.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=training-tutorials') == true){include('../codeInc/welcomeheadings/training.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=featured-photography') == true){include('../codeInc/welcomeheadings/featured.inc.php');}
    				else if(strrpos($currentURL, 'searchCat=photography-behind-scenes') == true){include('../codeInc/welcomeheadings/behind-scenes.inc.php');}
    				else if(strrpos($currentURL, 'weddings=true') == true && strrpos($currentURL, 'p=') == false){include('../codeInc/welcomeheadings/lukeweddings.inc.php');}
    				else if(strrpos($currentURL, 'p=') == true){}
    				else if(strrpos($currentURL, 'tag=') == true){echo('<div class="headingmain">Sorted By Tag: '.$_GET['tag'].'</div><div class="horizontalRuleTop"><img class="imageline" src="../../../../images/line.png" alt="" width="600px" /></div>');}
    				else {include('../codeInc/welcomeheadings/fullblog.inc.php');} ?>
    
            <div class="noresult">Sorry, we don't have any recent projects tagged under this category quite yet, but we will soon.  Please choose another Category on the navigational bar.</div>
            <div class="returnpagenoresult"><a href="javascript:history.back()"><< Return to Previous</a></div>
    
            <?php $limitPagePosts=6; 			//Limit Posts per page for pagination
    			$postsonpage=0;					//Tells us how many posts are on page after script run
    			$countLeftOrRight = 0; 			//Float the image left or right?
    			$postid = 0; 					//Defines individual post class
    			$hideheader = 'false';
    			$siteID = 'studio';
    
    		if (isset($_GET['searchCat'])){
    				$myCAT = $_GET['searchCat'];
    				$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    				query_posts('category_name='.$myCAT.''.'&posts_per_page='.$limitPagePosts.'&paged=' . $paged);
    			}
    			else if (isset($_GET['tag'])){
    				$myTAG = $_GET['tag'];
    				$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    				query_posts('tag='.$myTAG.''.'&posts_per_page='.$limitPagePosts.'&paged=' . $paged);
    			}
    			else { query_posts($query_string.'&posts_per_page='.$limitPagePosts.'');}
    
    		if(have_posts()) :
    			while(have_posts()) : the_post();
    				$postid++; 							//Incriment to determine post classes
    
    				//Get the needed Post INFO BEFORE ECHO
    				$link = get_permalink();		//Define Permalink
    				if ($lukeweddings == true){$link = $link . '&weddings=true'; $siteID = $link;}
    				$title = get_the_title();		//Title Of Post
    				$content = get_the_content();
    				$posttags = the_tags();
    				$category = get_the_category();
    				$postOutput = preg_replace('/<img[^>]+./','', $content);
    
                    if ($countLeftOrRight == 0){
                        $countLeftOrRight++;
                    }
                    else {
                        $countLeftOrRight = 0;
                    }
    
                    if($countLeftOrRight == 1){
                        images('1', '', '', 'imageleft image'. $postid, $siteID);}
                        else {images('1', '', '', 'imageright image' . $postid, $siteID);}
    
            		echo('<div class="post" id="post' . $postid . '">
                        <div class="heading heading' . $postid . '">
                            <a href="' . $link . '">' . $title . '</a>
                        </div>
                        <div class="content content' . $postid . '">'
                                . $postOutput .
                        '</div>
                        <div class="readmore readmore' . $postid . '"><a href="' . $link . '">Read More >></a></div>
    
                        <div class="postcategories"><span>Categorized Under: </span>' . $category . '</div>
                        <div class="posttags"><span>Tags: </span>' .  $posttags . '</div>
                        <div class="returnpage"><a href="javascript:history.back()"><< Return to Previous</a></div>
                        <div class="facebookShare facebookShare' . $postid . '">'
                             . fbshare_manual() .
                        '</div>
                        <div class="clearfloats"></div>
    					 <div class="horizontalRule horizontalRule'. $postid . '"><img class="imageline" src="../../../../images/line.png" alt="" width="600px" /></div>
                    </div>');
    
    			endwhile;
            	$postsonpage = $postid;
    			if($postsonpage == $limitPagePosts){
    				echo('<script type="text/javascript">
    					 	jQuery(".horizontalRule'.$postid.'").css("margin-bottom", "0px");
    					  </script>');
    			}
    			else {echo('<script type="text/javascript">
    					 	jQuery(".horizontalRule'.$postid.'").css("display", "none");
    					  </script>');}
    		endif; ?>
    
    </div>
    
    <div class="rightnav">
        <div class="rightnavcat">
            <div class="sortbycat">
                SORT BY CATEGORY:
            </div>
    
            <div class="categories">
                <a href="?searchCat=commercial-photography">Commercial Photography</a><br />
                <a href="?searchCat=event-photography">Events & Occasions</a><br />
                <a href="?searchCat=people-portraiture">People / Portraiture</a><br />
                <a href="?searchCat=adventures-travel-photography">Adventures & Travel</a><br />
                <a href="?searchCat=senior-portraits">Senior Portraits</a><br />
                <a href="?searchCat=creative-artistic-photography">Creative & Artistic Photos</a><br />
                <a href="?searchCat=wedding-photography">Wedding Photography</a><br />
                <a href="?searchCat=retouching-photoshop--editing-examples">Retouching / Photo Editing</a><br />
                <a href="?searchCat=links-tools">Links & Tools</a><br />
                <a href="?searchCat=training-tutorials-photography">Training & Tutorials</a><br />
                <a href="?searchCat=featured-photography">Our Work Featured</a><br />
                <a href="?searchCat=photography-behind-scenes">Behind the Scenes</a><br />
            </div><br />
        </div>
    
        <div class="rssfeed">
            <div class="rssindent">
                <?php if( class_exists('Add_to_Any_Subscribe_Widget') ) { Add_to_Any_Subscribe_Widget::display(); } ?>
            </div>
        </div>
    
    </div>
    <div class="clearfloats"></div>
    <div class="paginationstyle">
    	<?php wp_pagenavi(); ?>
    </div>
    
        <?php echo
        ('<script type="text/javascript">
    	 	 jQuery(document).ready(function() {
    
    				for(var i=1; i<='.$postsonpage.'; i++) {
    					var imghgt = jQuery(".image" + i).height();
    						if (imghgt == undefined) imghgt = 300;
    					var headinghgt = jQuery(".heading" + i).height();
    					var contenthgt = jQuery(".content" + i).height();
    					var desiredcontenthgt = imghgt - headinghgt - 35;
    					if (contenthgt > desiredcontenthgt){
    						var mod = desiredcontenthgt % 15;
    						desiredcontenthgt = desiredcontenthgt - mod + 2;
    						mod = mod + 3;
    						jQuery(".content" + i).css("overflow", "hidden");
    						jQuery(".content" + i).height(desiredcontenthgt);
    						jQuery(".readmore" + i).css("margin-top", mod + "px");
    						jQuery(".image" + i).css("margin-bottom", "0px");
    					}
    				}');
    
    			if($postsonpage == 0){
    				echo ('jQuery(".noresult").css("display", "block");
    						jQuery(".returnpagenoresult").css("display", "block");
    						jQuery(".headingmain").css("display", "none");
    						jQuery(".blogDesc").css("display", "none");
    						jQuery(".horizontalRuleTop").css("display", "none"); ');
    			}
    			else if(strrpos($currentURL, 'p=') == true){
    				echo ('jQuery(".rightnav").css("display", "none");
    						jQuery("#container").css("width", "840px");
    						jQuery(".content1").css("height", "100%");
    						jQuery(".content1").css("overflow", "hidden");
    						jQuery(".post").css("overflow", "hidden");
    						jQuery(".readmore").css("display", "none");
    						jQuery(".returnpage").css("display", "block");
    						jQuery(".paginationstyle").css("display", "none");
    						jQuery(".facebookShare").css("display", "block");
    						jQuery(".content1").css("margin-bottom", "15px");
    						jQuery(".imageleft").css("margin-bottom", "15px");
    						jQuery(".headingmain").css("display", "none");
    						jQuery(".blogDesc").css("display", "none");
    						jQuery(".horizontalRuleTop").css("display", "none");
    						jQuery(".horizontalRuleTop").css("display", "none");');
    				if (strrpos($currentURL, 'weddings=true') == false){
    						echo ('jQuery(".postcategories").css("display", "block");
    						jQuery(".posttags").css("display", "block");');
    				}
    			}
    
    			else if(strrpos($currentURL, 'weddings=true') == true){
    				echo ('jQuery(".rightnav").css("display", "none");
    						jQuery("#container").css("width", "840px");
    						jQuery(".current").css("border-color", "#2F0200");
    						jQuery(".imageline").css("width", "100%");');
    
    			}
    
    			echo ('
    		});		
    
    	</script>'); ?>
    
    <script type="text/javascript">
    	<?php
    
    ?>
    </script>
    
    <?php	if ($lukeweddings == true) { // note: three equal signs
    			include("../weddings/includes/footerblog.inc.php");
    		}
    		else include("includes/footer.inc.php");
    ?>
    
    </div>
    
    </body>
    
    </html>

Topic Closed

This topic has been closed to new replies.

About this Topic