How to get Isotope Wordpress plugin mintthemes work? - wordpress

I have installed the WordPress plugin Isotope from Mintthemes. But I don't get it to work. I have set the following snippet of code in my page.php and also filled in the optional settings for usage of custom post types.
<?php moveplugins_isotopes(); ?>
Added categories to my custom post type portfolio items but it doesn't work.
My code:
<?php moveplugins_isotopes(); ?>
<ul class="entrybox">
<?php
$args = array('post_type' => 'portfolio');
$loop = new WP_Query($args);
?>
<?php if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post(); ?>
<li class="grid_4 portfolio-post">
<a href="<?php the_permalink(); ?>">
<div class="thumbnail">
<img src="<?php print IMAGES; ?>/portfolio/thumbnails/thumbnail.png" alt="Thumbnail">
</div><!-- End .thumbnail -->
</a>
<div class="description">
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
</div><!-- End div.description -->
</li><!-- End li.grid_4 projectbox -->
<?php endwhile; ?>
<?php endif; ?>
</ul><!-- End ul.entrybox -->

The problem is that your li isn't using the post_class function in WordPress. It uses that post_class to identify which items are in the loop.
It should be something like
<li class="<?php post_class( array('grid_4', 'portfolio-post') ) ?>">
You can find out more about it here:
http://codex.wordpress.org/Function_Reference/post_class

Related

Creating Links to Custom Post Type's on Wordpress Page

I'm trying to have two things on a Wordpress page: a list of Custom Posts as well as the content of the custom posts. I would like the titles of the Custom Posts to link to the section of the page with the posts' content.
For example:
Item One
Item Two
Item Three
ITEM ONE HEADING
Item One content...
ITEM TWO HEADING
Item two content...
ITEM THREE HEADING
Item three content...
So "Item One" would link to "ITEM ONE HEADING". Here's the code I'm using which shows the Custom Post List as well as the content, but the list items link out to the Custom Post's page.
<ul>
<?php
$query = new WP_Query( array( 'post_type' => array( 'drilling' ) ) );
while ( $query->have_posts() ) : $query->the_post();
echo '<li><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></li>';
endwhile;
?>
</ul>
<?php wp_reset_query(); ?>
and
<?php query_posts( 'post_type=drilling'); ?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<section class="service-middle">
<div class="container">
<div class="service-middle-content sixteen columns">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><?php echo get_the_title($ID); ?> </h2>
<?php the_content(); ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<!-- /article -->
</div> <!--end service-middle-content-->
</div> <!--end container-->
</section> <!--end service-middle-->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
Thanks so much for any help!
-Dan
You want to use HTML Anchors
http://www.w3schools.com/html/html_links.asp
It is worth mentioning that you don't actually need to query the posts twice. You could you the WP get_posts function (https://codex.wordpress.org/Template_Tags/get_posts) to get the posts as an array and then loop through this array to generate a nav and your post contents.
Hope this helps!
<ul>
<?php
$query = new WP_Query( array( 'post_type' => array( 'drilling' ) ) );
while ( $query->have_posts() ) :
$query->the_post();
?>
<li><?php the_title(); ?></li>
<?php endwhile; ?>
</ul>
<?php wp_reset_query(); ?>
<?php query_posts( 'post_type=drilling'); ?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<section class="service-middle">
<div class="container">
<div class="service-middle-content sixteen columns">
<!-- Anchor Tag -->
<a name="post-<?php the_ID(); ?>"></a>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><?php echo the_title(); ?> </h2>
<?php the_content(); ?>
<br class="clear">
<?php edit_post_link(); ?>
</article>
<!-- /article -->
</div> <!--end service-middle-content-->
</div> <!--end container-->
</section> <!--end service-middle-->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>

WordPress custom post type pagination on Zylyz theme

Sorry for asking in my first question, but I have a big problem with my theme and nobody could solve it. Actually it's so simple:
I am using Zylyz recipe theme. I set the home page to a custom post type (recipes), but as you might guess, when I press the "Older Entries" button it gives "not found" error, because it tries to get ordinary blog posts, not "recipes" (you know, if I had enough blog post it wouldn't give error, but would show posts, not recipes).
So, how can I get rid of this problem?
Thank you very much in advance.
Here's the home page's codes:
<div id="content">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('post_type=recipes'.'&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="post clearfix" id="post-<?php the_ID(); ?>">
<?php
if ( has_post_thumbnail() ) { ?>
<img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=200&w=200&zc=1" alt="<?php the_title(); ?> Recipe"/>
<?php } else { ?>
<img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.jpg" alt="" />
<?php } ?>
<div class="cover">
<div class="title">
<h2><?php the_title(); ?></h2>
</div>
<div class="recipemeta">
<span class="cooktime"> <strong>ready in</strong> <?php $cooktime=get_post_meta($post->ID, 'wtf_cooktime', true); echo $cooktime; ?> mins </span> <span class="serve"> <strong>Serving:</strong> <?php $serving=get_post_meta($post->ID, 'wtf_serving', true); echo $serving; ?> people</span>
</div>
<div class="entry" align="justify">
<?php wpe_excerpt('wpe_excerptlength_recipe', ''); ?>
<div class="clear"></div>
</div>
</div>
</div>
<?php endwhile; ?>
<div class="clear"></div>
<?php getpagenavi(); ?>
<?php $wp_query = null; $wp_query = $temp;?>
</div>

the_author is empty when not logged in

Is there a reason why the_author should return an empty string on the first page when the user is not logged in, but return the author name just as it should when more posts are loaded through AJAX ?
The loop is the same in both cases.
Please help me resolve this issue as I'm clueless and I need it fixed ASAP to launch my site.
Here's the whole index.php:
<?php
get_header();
get_sidebar();
?>
<!-- MAIN DIV -->
<div id='content_and_floater'>
<?php get_template_part('social_floater'); ?>
<div id='content'>
<?php get_template_part('loop'); ?>
</div>
</div>
<?php get_template_part('loader'); ?>
<!-- MAIN DIV -->
<?php
get_footer();
?>
And here's how the infinitePaginator calls the loop in functions.php (the function is called when scrolled down to the bottom or the loader link is clicked):
function wp_infinitepaginate(){
$loopFile = $_POST['loop_file'];
$paged = $_POST['page_no'];
$posts_per_page = get_option('posts_per_page');
# Load the posts
query_posts(array('paged' => $paged ));
get_template_part( $loopFile );
exit;
}
You can see the behaviour at test.nowillnoskill.net.
In single posts it's not working either. My guess is that query_posts(array('paged' => $paged )); changed something in the query, but I don't know what is it.
I tried to insert setup_postdata($post); just after the_post() in loop.php as I found that worked for someone, but it doesn't for me.
I also tried to insert
query_posts(array('paged' => 1 ));
before calling the loop file in index.php, but no posts at all were shown.
Here is my loop.php:
<?php while ( have_posts() ) : the_post() ?>
<!-- POST1 -->
<article class='post'>
<header class='post_header'>
<?php
global $current_user;
$current_user = wp_get_current_user();
if (!empty($current_user)) {
$pid = get_the_id();
$uid = $current_user->ID;
$title = (is_favorite($pid, $uid)) ?
'Remove from favorites' :
'Add to favorites';
$trans = (is_favorite($pid, $uid)) ?
'' :
' transparent';
?>
<div>
<h2>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
<?php if (is_user_logged_in()) { ?>
<a title='<?php echo $title ?>' class='post_favorite' href='#' alt='fpid=<?php echo $pid ?>uid=<?php echo $uid ?>'>
<span class='symbol<?php echo $trans ?>'>R</span>
</a>
<?php } ?>
</div>
<div class='post_header_div'>
<strong class='post_category'>
<?php echo get_the_category_list(', '); ?>
</strong>
<strong class='post_author'>
<span class='symbol'>U</span>
<?php the_author(); ?>
</strong>
</div>
<div>
<span class='post_author'>
<?php edit_post_link('[edit]'); ?>
</span>
</div>
<?php } ?>
</header>
<figure class='post_image'>
<!--<img src='design/img/flashkick.png' alt='logo' />-->
<?php the_post_thumbnail(); ?>
</figure>
<div class='post_perex'>
<?php the_content('Read more'); ?>
</div>
<div class='space'></div>
<footer class='post_footer'>
<div class='post_footer_top'>
<div class='post_tags'>
<?php the_tags('', '', ''); ?>
</div>
<div class='post_time'>
<time datetime="<?php the_time('Y-m-d'); ?>" pubdate>
<span class='symbol'>P </span>
<?php relative_post_the_date(); ?>
</time>
</div>
</div>
</footer>
<div class='space'></div>
</article>
<?php endwhile; ?>
Author informations are given by Wordpress in post informations.
Try to do a var_dump on your query_posts result, you should find where the author name is stored, to display it properly.
Can you please show your loop template ? At least the part displaying the author.

How can I have multiple loops on one page in Wordpress?

I am using a nice jquery slideshow plugin I found and trying to get it to work into my Wordpress template. I have tried the code below in various formats but I can't seem to get it the way I want.
The first part is where the title and content of the post reads into the slider, using a specific category. I have 3 of these sections:
<div class="details_wrapper">
<div class="details">
<div class="detail">
<?php query_posts('cat_ID=7&showposts=1');
if (have_posts()) : while (have_posts()) : the_post();?>
<h2 class="Lexia-Bold"><a href="<?php the_permalink() ?>">
<?php the_title() ?></a><?php the_excerpt(); ?></h2>
<?php endwhile; endif;
?>
</div><!-- /detail -->
<div class="detail">
<?php query_posts('cat_ID=8&showposts=1');
if (have_posts()) : while (have_posts()) : the_post();?>
<h2 class="Lexia-Bold"><a href="<?php the_permalink() ?>">
<?php the_title() ?></a><?php the_excerpt(); ?></h2>
<?php endwhile; endif;
?>
</div><!-- /detail -->
<div class="detail">
<?php query_posts('cat_ID=9&showposts=1');
if (have_posts()) : while (have_posts()) : the_post();?>
<h2 class="Lexia-Bold"><a href="<?php the_permalink() ?>">
<?php the_title() ?></a><?php the_excerpt(); ?></h2>
<?php endwhile; endif;
?>
</div><!-- /detail -->
</div><!-- /details -->
</div>
Now this actually works, but I just need it to post the title and excerpt from one of the posts from the category noted. I was reading that I may need to add the wp_reset_query(); line somewhere to destroy the previous loop's query, but I'm not sure.
Here's the second part of the code where the post's featured image is retrieved:
<div class="item item_1">
<?php query_posts('cat_ID=7&posts_per_page=1'); ?>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
</div><!-- /item -->
<div class="item item_2">
<?php query_posts('cat_ID=8&posts_per_page=1'); ?>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
</div><!-- /item -->
<div class="item item_3">
<?php query_posts('cat_ID=9&posts_per_page=1'); ?>
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
</div>
Any help would be greatly appreciated :) Here's an example.
Have you tried using...
query_posts('cat_ID=9&posts_per_page=1');
Or I have used get_post before as while to get certain amount of post like so...
<?php
global $post;
$myposts = get_posts('posts_per_page=1&numberposts=-1&category=1');
foreach($myposts as $post) :
?>
<h6><?php the_title(); ?></h6>
<?php setup_postdata($post);?>
<?php the_excerpt(); ?>
<?php endforeach; ?>
</div>
If its just one post you want you wouldn't really need the foreach or while loop.
I used the method Tianbo84 suggested above both to query the posts AND the featured images from that post to finish the job :) Thanks Tianbo84! To my understanding, the get_posts and <?php endforeach; ?> lines were key... like opening a query and then closing it once the data was retrieved.

WP – Content code keeps subpage from appearing in sidebar

In one of my wordpress templates, the content code seems to keep the subpage menu from displaying in the sidebar. When ever I remove all code from the content div, the subpage menu appears as expected.
Could anyone point out where the code goes wrong?
Any help would be greatly appreciated!
<div id="content">
<div class="pageinfo clearfix">
<div class="info">
<h1><?php the_title();?></h1>
</div>
</div>
<?php
global $more;
// set $more to 0 in order to only get the first part of the post
$more = 0;
global $post;
$myposts = query_posts("category_name=intern&posts_per_page=3");
foreach($myposts as $post) :
setup_postdata($post);
?>
<div class="postitem clearfix">
<div class="new"></div>
<div class="info">
<h2><?php the_title()?></h2>
<?php the_date()?> | Skrevet af <?php the_author_posts_link(); ?> | Gemt under:
<?php
// heres just the name and permalink:
foreach((get_the_category()) as $category) {
$category_name = $category->category_nicename . ' ';
$category_link = get_category_link($category->cat_ID);
echo "<a href='$category_link'>$category_name</a>";
}
?>
</div>
<?php
$thumb = get_post_meta($post->ID,'_thumbnail_id',false);
$thumb = wp_get_attachment_image_src($thumb[0], false);
$thumb = $thumb[0];?>
<?php if($thumb != NULL) { ?>
<a href="<?php the_permalink() ?>">
<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $thumb ?>&h=110&w=110&zc=1" alt="<?php the_title(); ?>" width="110" height="110" class="leftImage" >
</a>
<?php } ?>
<?php the_content('<br />Læs resten her » '); ?>
<div class="clearBoth"></div>
</div><!-- /postitem -->
<?php endforeach; ?>
</div><!-- /content -->
try rewind_posts(); or wp_reset_query(); somewhere before your sidebar is loaded up (and after the endforeach).

Resources