• Hello,

    I usually find the answer to simple question but this one baffle me :

    i am trying to get the category from the current post and have them show on that same page , WITH the category image.

    here are the code i have but of course nothing work

    <p>Categories: <?php the_category( $separator, $parents, $post_id ); ?></p>
    
    					<div class="category-wrap-table">
    						<div class="category-wrap-row">
    							<div class="icon" style="background: url('{timthumb src => $category->icon, w => 35, h => 35 }') no-repeat center top;"></div>
    							<div class="description">
    								<h3><a href="{!$category->link}">{!$category->name}</a></h3>
    								{!$category->excerpt}
    							</div>
    						</div>
    					</div>

    here the website in progress : mooogli.com

    and here the single page wich as 3 or 4 category, i should be able to see all the relevant category icon in this.

    https://www.mooogli.com/item/basepleinairstefoy/

    tanxs

Viewing 5 replies - 1 through 5 (of 5 total)
  • https://codex.www.ads-software.com/Function_Reference/the_category#Examples

    <p>Categories: <?php the_category(' '); ?></p>

    what template are you using the code in?

    what is the full code of the template?

    have you reviewed https://codex.www.ads-software.com/Function_Reference/get_the_category

    Thread Starter inickqc

    (@inickqc)

    Hello,

    yes i have review the codex, but i didnt get anywhere.

    <p>Categories: <?php the_category(‘ ‘); ?></p> will only return the word : category

    what template are you using the code in?

    what is the full code of the template?

    are you using ‘categories’ or custom taxonomies?

    where exactly do you want to show the categories?

    what theme are you working with?

    where did you get your code snippet from?

    is the ‘timthumb’ part referring to a plugin you are using?
    if so, which plugin?

    do you set $category anywhere in your code?

    have you explored using get_the_category() ?

    Thread Starter inickqc

    (@inickqc)

    I use a template call WP Directory by AIT Theme.

    I ask them but got no answers, probably because they dont help customise their product. they sell as is.

    here the full code of the item template where i want to add the code

    {extends $layout}
    
    {block content}
    
    <article id="post-{$post->id}" class="{$post->htmlClasses}">
    
    	<header class="entry-header">
    
    		<h1 class="entry-title">
    			<a href="{$post->permalink}" title="Permalink to {$post->title}" rel="bookmark">{$post->title}</a>
    			{if $rating}
    			<span class="rating">
    				{for $i = 1; $i <= $rating['max']; $i++}
    					<span class="star{if $i <= $rating['val']} active{/if}"></span>
    				{/for}
    			</span>
    			{/if}
    		</h1>
    
    		<div class="category-breadcrumb clearfix">
    			<span class="here">{__ 'You are here'}</span>
    			<span class="home"><a href="{!$homeUrl}">{__ 'Home'}</a>&nbsp;&nbsp;></span>
    			{foreach $ancestors as $anc}
    				{first}<span class="ancestors">{/first}
    				<a href="{!$anc->link}">{!$anc->name}</a>&nbsp;&nbsp;>
    				{last}</span>{/last}
    			{/foreach}
    			{ifset $term}<span class="name"><a href="{!$term->link}">{!$term->name}</a></span>{/ifset}
    			<span class="title"> >&nbsp;&nbsp;{$post->title}</span>
    		</div>
    
    	</header>
    
    <p>Categories: <?php the_category(' '); ?></p>
    
    	<div class="entry-content clearfix">
    
    		<div class="item-image">
    
    			{if $post->thumbnailSrc}
    			<img src="{timthumb src => $post->thumbnailSrc, w => 140, h => 200}" alt="{__ 'Item image'}">
    			{/if}
    
    			{if isset($options['emailContactOwner']) && (!empty($options['email']))}
    			<a id="contact-owner-button" class="contact-owner button" href="#contact-owner-form-popup">{_ "Contact owner"}</a>
    			{/if}
    
    			{if (isset($themeOptions->directory->enableClaimListing)) && (!$hasAlreadyOwner)}
    			<a id="claim-listing-button" class="claim-listing-button" href="#claim-listing-form-popup">{_ "Own this business?"}</a>
    			{/if}
    
    		</div>
    
    		{if isset($options['emailContactOwner']) && (!empty($options['email']))}
    		<!-- contact owner form -->
    		<div id="contact-owner-form-popup" style="display:none;">
    			<div id="contact-owner-form" data-email="{$options['email']}">
    
    				<h3>{_ "Contact owner"}</h3>
    
    				<div class="input name">
    					<input type="text" class="cowner-name" name="cowner-name" value="" placeholder="{_ 'Your name'}">
    				</div>
    				<div class="input email">
    					<input type="text" class="cowner-email" name="cowner-email" value="" placeholder="{_ 'Your email'}">
    				</div>
    				<div class="input subject">
    					<input type="text" class="cowner-subject" name="cowner-subject" value="" placeholder="{_ 'Subject'}">
    				</div>
    				<div class="input message">
    					<textarea class="cowner-message" name="cowner-message" cols="30" rows="4" placeholder="{_ 'Your message'}"></textarea>
    				</div>
    				<button class="contact-owner-send">{_ "Send message"}</button>
    
    				<div class="messages">
    					<div class="success" style="display: none;">{_ "Your message has been successfully sent"}</div>
    					<div class="error validator" style="display: none;">{_ "Please fill out email, subject and message"}</div>
    					<div class="error server" style="display: none;"></div>
    				</div>
    
    			</div>
    		</div>
    		{/if}
    
    		{if (isset($themeOptions->directory->enableClaimListing)) && (!$hasAlreadyOwner)}
    		<!-- claim listing form -->
    		<div id="claim-listing-form-popup" style="display:none;">
    			<div id="claim-listing-form" data-item-id="{$post->id}">
    
    				<h3>{_ "Enter your claim"}</h3>
    
    				<div class="input name">
    					<input type="text" class="claim-name" name="claim-name" value="" placeholder="{_ 'Your name'}">
    				</div>
    				<div class="input email">
    					<input type="text" class="claim-email" name="claim-email" value="" placeholder="{_ 'Your email'}">
    				</div>
    				<div class="input number">
    					<input type="text" class="claim-number" name="claim-number" value="" placeholder="{_ 'Your phone number'}">
    				</div>
    				<div class="input username">
    					<input type="text" class="claim-username" name="claim-username" value="" placeholder="{_ 'Username'}">
    				</div>
    				<div class="input message">
    					<textarea class="claim-message" name="claim-message" cols="30" rows="4" placeholder="{_ 'Your claim message'}"></textarea>
    				</div>
    				<button class="claim-listing-send">{_ "Submit"}</button>
    
    				<div class="messages">
    					<div class="success" style="display: none;">{_ "Your claim has been successfully sent"}</div>
    					<div class="error validator" style="display: none;">{_ "Please fill out inputs!"}</div>
    					<div class="error server" style="display: none;"></div>
    				</div>
    
    			</div>
    		</div>
    		{/if}
    
    		{!$post->content}
    
    	</div>
    
    	{ifset $themeOptions->directory->showShareButtons}
    	<div class="item-share">
    		<!-- facebook -->
    		<div class="social-item fb">
    			<iframe src="//www.facebook.com/plugins/like.php?href={$post->permalink}&send=false&layout=button_count&width=113&show_faces=true&font&colorscheme=light&action=like&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:113px; height:21px;" allowTransparency="true"></iframe>
    		</div>
    		<!-- twitter -->
    		<div class="social-item">
    			<a href="https://twitter.com/share" class="twitter-share-button" data-url="{$post->permalink}" data-text="{$themeOptions->directory->shareText}" data-lang="en">Tweet</a>
    			<script>!function(d,s,id){ var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){ js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
    		</div>
    		<!-- google plus -->
    		<!-- Place this tag where you want the +1 button to render. -->
    		<div class="social-item">
    			<div class="g-plusone"></div>
    			<!-- Place this tag after the last +1 button tag. -->
    			<script type="text/javascript">
    			  (function() {
    			    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    			    po.src = 'https://apis.google.com/js/plusone.js';
    			    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    			  })();
    			</script>
    		</div>
    
    	</div>
    	{/ifset}
    
    	<hr>
    	<div class="item-info">
    
    		{if (!empty($options['address'])) || (!empty($options['gpsLatitude'])) || (!empty($options['telephone'])) || (!empty($options['email'])) || (!empty($options['web']))}
    		<dl class="item-address">
    
    			<dt class="title"><h4>{__ 'Our address'}</h4></dt>
    
    			{if (!empty($options['address']))}
    			<dt class="address">{__ 'Address:'}</dt>
    			<dd class="data">{!$options['address']}</dd>
    			{/if}
    
    			{if (!empty($options['gpsLatitude']))}
    			<dt class="gps">{__ 'GPS:'}</dt>
    			<dd class="data">{$options['gpsLatitude']}, {$options['gpsLongitude']}</dd>
    			{/if}
    
    			{if (!empty($options['telephone']))}
    			<dt class="phone">{__ 'Telephone:'}</dt>
    			<dd class="data">{$options['telephone']}</dd>
    			{/if}
    
    			{if (!empty($options['email']))}
    			<dt class="email">{__ 'Email:'} </dt>
    			<dd class="data"><a href="mailto:{!$options['email']}">{!$options['email']}</a></dd>
    			{/if}
    
    			{if (!empty($options['web']))}
    			<dt class="web">{__ 'Web:'} </dt>
    			<dd class="data"><a href="{!$options['web']}">{!$options['web']}</a></dd>
    
    			{/if}
    
    		</dl>
    		{/if}
    
    		{if (!empty($options['hoursMonday'])) || (!empty($options['hoursTuesday'])) || (!empty($options['hoursWednesday'])) || (!empty($options['hoursThursday'])) || (!empty($options['hoursFriday'])) || (!empty($options['hoursSaturday'])) || (!empty($options['hoursSunday']))}
    		<dl class="item-hours">
    
    			<dt class="title"><h4>{__ 'Opening Hours'}</h4></dt>
    
    			{if (!empty($options['hoursMonday']))}
    		    <dt class="day">{__ 'Monday:'}</dt>
    		    <dd class="data">{!$options['hoursMonday']}</dd>
    		    {/if}
    
    		    {if (!empty($options['hoursTuesday']))}
    		    <dt class="day">{__ 'Tuesday:'}</dt>
    		    <dd class="data">{!$options['hoursTuesday']}</dd>
    		    {/if}
    
    		    {if (!empty($options['hoursWednesday']))}
    		    <dt class="day">{__ 'Wednesday:'}</dt>
    		    <dd class="data">{!$options['hoursWednesday']}</dd>
    		    {/if}
    
    		    {if (!empty($options['hoursThursday']))}
    		    <dt class="day">{__ 'Thursday:'}</dt>
    		    <dd class="data">{!$options['hoursThursday']}</dd>
    		    {/if}
    
    		    {if (!empty($options['hoursFriday']))}
    		    <dt class="day">{__ 'Friday:'}</dt>
    		    <dd class="data">{!$options['hoursFriday']}</dd>
    		    {/if}
    
    		    {if (!empty($options['hoursSaturday']))}
    		    <dt class="day">{__ 'Saturday:'}</dt>
    		    <dd class="data">{!$options['hoursSaturday']}</dd>
    		    {/if}
    
    		    {if (!empty($options['hoursSunday']))}
    		    <dt class="day">{__ 'Sunday:'}</dt>
    		    <dd class="data">{!$options['hoursSunday']}</dd>
    		    {/if}
    
    		</dl>
    		{/if}
    
    	</div>
    
    	{if isset($options['gpsLatitude'], $options['gpsLongitude']) && !(empty($options['gpsLatitude']) && empty($options['gpsLongitude']))}
    	<div class="item-map clearfix">
    	</div>
    	{/if}
    
    	<hr>
    
    	{if (!empty($options['$$$']))}
    	<div class="item-alternative-content">
    		{!do_shortcode($options['$$$'])}
    	</div>
    	{/if}
    
    </article><!-- /#post-{$post->id} -->
    
    {ifset $themeOptions->rating->enableRating}
    	{!getAitRatingElement($post->id)}
    {/ifset}
    
    {include comments-dir.php, closeable => (isset($themeOptions->general->closeComments)) ? true : false, defaultState => $themeOptions->general->defaultPosition}
    
    {ifset $themeOptions->advertising->showBox4}
    <div id="advertising-box-4" class="advertising-box">
        {!$themeOptions->advertising->box4Content}
    </div>
    {/ifset}
    
    {/block}
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘getting the category of the current post’ is closed to new replies.