I created a custom post type and then I did the following:
In the homepage I have a normal loop which I display the content of that post type like custom fields,thumbnail etc.
Then, via functions.php I created a widget that allows me to show 2 custom post types based on category.
All works fine, but when I view the page the custom field does not show.
I used this code which works in my first loop of the homepage:
<?php echo get_post_meta($post->ID, 'game_offer', true); ?>
For some reason that does not work in the loop that I have in the functions for the widget.
Here the image where you can see that the custom field exists in the backend.
My code in the function looks like this in case needed:
class My_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'my_widget',
'description' => 'Custom Post Type widget',
);
parent::__construct( 'my_widget', 'Cutom Post Type Widget', $widget_ops );
}
public function widget( $args, $instance ) {
echo '<section id="custom_post_type_widget">';
?>
<div class="top_bar">
<h3 class="border-radius">Top Casino Offers</h3>
</div>
<?php
$mypost = array(
'post_type' => 'game_reviews',
'posts_per_page' => 2,
'type' => 'top-casino-offers',
);
$loop = new WP_Query( $mypost );
while ( $loop->have_posts() ) : $loop->the_post();?>
<div class="custom_post_widget_container flex outer">
<div class="left">
<?php
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
if ( has_post_thumbnail() ) {
echo '<div class="game_imag">';
echo the_post_thumbnail();
echo '</div>';
}
?>
</div>
<div class="right">
<div>
<div class="flex">
<div>
<p>
<span class="title"><?php the_title(); ?></span> | <span class="rating">
<?php
$nb_stars = intval( get_post_meta( get_the_ID(), 'game_rating', true ) );
for ( $star_counter = 1; $star_counter <= 5; $star_counter++ ) {
if ( $star_counter <= $nb_stars ) {
echo '<img src="'.get_template_directory_uri().'/images/icon.png"/>';
} else {
echo '<img src="'.get_template_directory_uri().'/images/grey.png"/>';
}
}
?>
</span>
</p>
<ul class="custom-field-list">
<li><?php echo get_post_meta($post->ID, 'game_offer', true); ?></li>
</ul>
<?php echo get_post_meta($post->ID, 'game_offer', true); ?>
</div>
<div class="right">
<ul class="play-reviews flex">
<li>Play Now</li>
<li>Reviews</li>
</ul>
</div>
</div>
<p><?php echo get_the_excerpt(); ?><a class="read-more" href="<?php the_permalink(); ?>">Read More</a></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query();
echo '</section>';
}
}
add_action( 'widgets_init', function(){
register_widget( 'My_Widget' );
});
How can I show my custom field?
Use query_posts instead of WP_Query
<?php
class My_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'my_widget',
'description' => 'Custom Post Type widget',
);
parent::__construct( 'my_widget', 'Cutom Post Type Widget', $widget_ops );
}
public function widget( $args, $instance ) {
echo '<section id="custom_post_type_widget">';
?>
<div class="top_bar">
<h3 class="border-radius">Top Casino Offers</h3>
</div>
<?php
global $post;
$game_reviews_args=array(
'post_type' => 'game_reviews',
'post_status' => 'publish',
'showposts' => 2,
'tax_query' => array(
array(
'taxonomy' => 'type', //taxonomy name
'terms' => 'top-casino-offers', //category name slug
'field' => 'slug'
)
),
'orderby' => 'date',
'order' => 'DESC'
);
query_posts($game_reviews_args);
if (have_posts()) :
while (have_posts()) : the_post();
?>
<div class="custom_post_widget_container flex outer">
<div class="left">
<?php
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
if ( has_post_thumbnail() ) {
echo '<div class="game_imag">';
echo the_post_thumbnail();
echo '</div>';
}
?>
</div>
<div class="right">
<div>
<div class="flex">
<div>
<p>
<span class="title"><?php the_title(); ?></span> | <span class="rating">
<?php
$nb_stars = intval( get_post_meta( $post->ID, 'game_rating', true ) );
for ( $star_counter = 1; $star_counter <= 5; $star_counter++ ) {
if ( $star_counter <= $nb_stars ) {
echo '<img src="'.get_template_directory_uri().'/images/icon.png"/>';
} else {
echo '<img src="'.get_template_directory_uri().'/images/grey.png"/>';
}
}
?>
</span>
</p>
<ul class="custom-field-list">
<li><?php echo get_post_meta($post->ID, 'game_offer', true); ?></li>
</ul>
<?php echo get_post_meta($post->ID, 'game_offer', true); ?>
</div>
<div class="right">
<ul class="play-reviews flex">
<li>Play Now</li>
<li>Reviews</li>
</ul>
</div>
</div>
<p><?php echo get_the_excerpt(); ?><a class="read-more" href="<?php the_permalink(); ?>">Read More</a></p>
</div>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_query();
echo '</section>';
}
}
add_action( 'widgets_init', function(){
register_widget( 'My_Widget' );
});
?>
So after all I figured that all I needed was the global $post variable before the WP_Query instance:
global $post;
Related
I'm new in wordpress. I'm trying load custom field of post from function.php. Below is code for function post grid layout function where I use custom field:
$args = array(
'post_type' => 'post',
'category_name' => 'category',
'posts_per_page' => -1,
'orderby' => 'ID',
'order' => 'ASC'
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
$c = 1;
$bpr = 5;
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div class="member">
<div class="div-block-image">
<?php the_post_thumbnail(); ?>
</div>
<div class="div-block-29 w-clearfix">
<div class="text-block-21"><?php the_title(); ?></div>
<div class="text-block-22">subTitle</div>
<div class="text-block-23">Text...</div>
<a href="<?php the_permalink() ?>" class="more w-inline-block">
<div class="text-block-24">More</div>
</a>
<p><?php echo get_post_meta($post->ID, 'linkedin', true); ?></p> // custom-field
<p><?php echo get_post_meta($post->ID, 'bio', true); ?></p>
<a href="#" target="_blank" class="link-block w-inline-block">
<div class="biotxt">bio</div>
</a>
<a href="#" target="_blank" class="link-block w-inline-block">
<div class="text-block-20"></div>
</a>
</div>
</div>
<?
if( $c == $bpr ) {
echo '<div class="clear"></div>';
$c = 0;
}
$c++;
endwhile;
} else {
_e( '<h2>Oops!</h2>', 'rys' );
_e( '<p>Sorry, seems there are no post at the moment.</p>', 'rys' );
}
wp_reset_postdata();
I want to load this function from template page. All is loading normally except custom field:
<p><?php echo get_post_meta($post->ID, 'linkedin', true); ?></p>
If run function code from template page its running normal. Any ideas?
$post->ID is not correct, as it's picking up the ID from the global $post object, which just happens to be the same when you're on the template page, but not necessarily when you're using it in a function in functions.php. Use get_the_ID() instead.
Within your custom loop, you will want to update those to use: get_the_ID() and not $post->ID.
<p><?php echo get_post_meta(get_the_ID(), 'linkedin', true); ?></p>
This will get the ID from the current loop.
Ref: https://developer.wordpress.org/reference/functions/get_the_id/
I created a custom post type called "library", with its "documentation" taxonomy; The problem occurs in the pagination of the taxonomy template (taxonomy-documentation.php).
I have determined a number of "18" posts per page, for the number of posts there should be "7" pages, but I list "16" pages, the pages from "8" to "16" are empty.
The url of archive for the taxonomy is: Documentation Archive
The template loop is as follows:
<?php
$term = $wp_query->queried_object;
$getterm = $term->slug; // get current slug (E.g. winter2015)
$args = (array(
'post_type' => 'library',
'showposts' => 18,
'paged'=>$paged,
'tax_query' => array(
array(
'taxonomy' => 'documentation',
'field' => 'slug',
'terms' => $getterm
),
),
) );
$query = new wp_query( $args );
if ( $query -> have_posts() ) : while ( $query -> have_posts() ) : $query -> the_post(); ?>
<?php setPostViews(get_the_ID()); ?>
<div class="col-md-2">
<?php if ( get_post_meta( get_the_ID(), 'download_image', true ) ) : ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php get_the_title(); ?>">
<?php
$postID = $post->ID;
$imageURI = get_post_meta($postID, 'download_image', true);
$attachmentID = pn_get_attachment_id_from_url ($imageURI);
$imagearray = wp_get_attachment_image_src( $attachmentID, 'full');
$imageURI = $imagearray[0];
$thumbarray = wp_get_attachment_image_src( $attachmentID, 'library-thumbnail');
$thumb_imageURI = $thumbarray[0];
echo "<img class='document-thumbnail' src='". $thumb_imageURI . "' alt='". get_the_title() ."' />";
?>
</a>
<?php endif; ?>
<a class="document-title" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo mb_strimwidth(get_the_title(), 0, 40, '...'); ?></a><br />
<span><?php echo __('Published by', 'cyberdocentes'); ?> <a class="author-link" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"><?php the_author(); ?></a></span>
</div>
<?php endwhile; rewind_posts(); ?>
<div class="clear"></div>
<div id="pagination">
<?php include(TEMPLATEPATH . '/pagenavi.php'); if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<div class="navigation">
<div class="alignleft">
<?php next_posts_link(__('Next posts','cyberdocentes')); ?>
</div>
<div class="alignright">
<?php previous_posts_link(__('Previous posts','cyberdocentes')); ?>
</div>
</div>
<?php } ?>
</div>
<div class="clear"></div>
<?php else : ?>
<?php endif; ?>
<?php flush(); ?>
Solved code:
<div class="documents-list">
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'documentation' ) );
global $wp_query;
query_posts( array_merge( $wp_query->query, array( 'posts_per_page' => 18 ) ) );
if (have_posts()) : while ( have_posts() ) : the_post(); ?>
//CODE OF THE ARTICLES HERE
<?php endwhile; rewind_posts(); ?>
<?php endif; ?>
<div class="clear"></div>
<div id="pagination">
<?php include(TEMPLATEPATH . '/pagenavi.php'); if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<div class="navigation">
<div class="alignleft">
<?php next_posts_link(__('Next posts','cyberdocentes')); ?>
</div>
<div class="alignright">
<?php previous_posts_link(__('Previous posts','cyberdocentes')); ?>
</div>
</div>
<?php } ?>
</div>
<div class="clear"></div>
<?php flush(); ?>
</div>
I have a custom post type "events" and I want to display the events in a table of 3 columns with pagination using code in wordpress.
This is what I did so far but that displays it as a list.
$loop = new WP_Query( array( 'post_type' => 'events' , 'posts_per_page' => 3) );
$count = $loop->post_count;
if ( $loop->have_posts() ) :
?>
<h2 style="position:relative;top:100px" align="center"> News & Events</h2>
<div id = "menu" style="position:relative;top:100px;left:350px">
<ul>
<li class = "aa"><a class="anchor" id="all" href="#">All</a></li>
<li class = "aa"><a class="anchor" id ="videos" href="#">Videos</a></li>
<li class = "aa"><a class="anchor" name = "links" id="links" href="#">Links</a></li>
<li class = "aa"><a class="anchor" id = "our events" name ="our events" href="#">Our Events</a></li>
</ul>
</div>
<br>
<br><br>
<?php
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="pindex" style="position:relative;top:100px;left:-450px">
<?php if ( has_post_thumbnail() ) { ?>
<div class="pimage">
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="ptitle">
<h2><?php
echo get_the_title() ?></h2>
<div style="width:20%;position:relative;top:10px;left:550px" ><?php echo the_content();?> </div>
</div>
</div>
<?php
endwhile;
if ( $loop->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Previous', 'domain' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Next <span class="meta-nav">→</span>', 'domain' ) ); ?></div>
</div>
<?php endif;
endif;
wp_reset_postdata();
Can someone help me with this?
You use this method for display custom post events and pagination as it is
$args = array(
'post_type' => 'events',
'posts_per_page' => 3
);
$posts_array = get_posts( $args );
// print_r($posts_array);
foreach ( $posts_array as $post ){
echo $post->ID;
}
I'm currently developing a Wordpress theme for a project and im looking for a way to exclude posts format from my widget and just keep the standard post format to show in the widget and i dont know where i have to put the code to exclude the post formats
and this the code of my tabs widget
<?php
add_action( 'widgets_init', 'widget_tabs_box' );
function widget_tabs_box(){
register_widget( 'widget_tabs' );
}
class widget_tabs extends WP_Widget {
function widget_tabs() {
$widget_ops = array( 'description' => 'Most Popular, Recent, Comments, Tags' );
$this->WP_Widget( 'widget_tabs',theme_name .'- Tabbed ', $widget_ops );
}
function widget( $args, $instance ) {
<if( empty($instance['posts_number']) || $instance['posts_number'] == ' ' || !is_numeric($instance['posts_number'])) $posts_number = 5;
else $posts_number = $instance['posts_number'];
?>
<div class="widget" id="tabbed-widget">
<div class="widget-container">
<div class="widget-top">
<ul class="tabs posts-taps">
<li class="tabs"><?php _e( 'Popular' , 'aya' ) ?></li>
<li class="tabs"><?php _e( 'Recent' , 'aya' ) ?></li>
<li class="tabs"><?php _e( 'Comments' , 'aya' ) ?></li>
<li class="tabs" style="margin-left:0"><?php _e( 'Tags' , 'aya' ) ?></li>
</ul>
</div>
<div id="main-warp">
<div id="tab1" class="tabs-wrap">
<ul>
<!--latest news-->
<?php aya_popular_posts( $posts_number ) ?>
</ul>
</div>
<div id="tab2" class="tabs-wrap">
<ul>
<?php aya_last_posts( $posts_number )?>
</ul>
</div>
<div id="tab3" class="tabs-wrap">
<ul>
<?php last_comments( $posts_number );?>
</ul>
</div>
<div id="tab4" class="tabs-wrap tagcloud">
<?php wp_tag_cloud( $args = array('largest' => 8,'number' => 25,'orderby'=> 'count', 'order' => 'DESC' )); ?>
</div>
</div>
</div>
</div><!-- .widget /-->
<?php
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['posts_number'] = strip_tags( $new_instance['posts_number'] );
return $instance;
}
function form( $instance ) {
$defaults = array( 'posts_number' => 5 );
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<p>
<label for="<?php echo $this->get_field_id( 'posts_number' ); ?>">Number of items to show : </label>
<input id="<?php echo $this->get_field_id( 'posts_number' ); ?>" name="<?php echo $this->get_field_name( 'posts_number' ); ?>" value="<?php echo $instance['posts_number']; ?>" size="3" type="text" />
</p>
<?php
}
}
?>
and this is the code of the last posts function
function aya_last_posts($numberOfPosts = 5 , $thumb = true){
global $post;
$orig_post = $post;
$lastPosts = get_posts('numberposts='.$numberOfPosts);
foreach($lastPosts as $post): setup_postdata($post);
?>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() && $thumb ) : ?>
<div class="hole-post">
<div class="post-thumbnail">
<?php aya_thumb('aya-medium'); ?><span class="overlay-icon"></span>
</div><!-- post-thumbnail /-->
<?php endif; ?>
<span class="ss-view">
<?php echo getPostViews(get_the_ID());?>
</span>
<div class="tabtitle"><h3><?php echo the_title(); ?></h3></div>
</li></div><?php endforeach; $post = $orig_post; }
If the last posts section is giving you troubles because of the image thumbnail, the fastest way would be to remove the image from the block. it seems the function accepts a second parameter so, instead of
<?php aya_last_posts( $posts_number )?>
try with
<?php aya_last_posts( $posts_number,false )?>
and see if it works.
As a sidenote: I see a closing </li> element inside the function. I'm pretty sure that there was an opening tag accidentally removed.
Edit: I saw your clarification. Look at the bennining of aya_last_posts, it says
$lastPosts = get_posts('numberposts='.$numberOfPosts);
get_posts accepts parameters such as how many posts to retrieve, and of which type.
Just replace it with
$lastPosts = get_posts(array('numberposts'=>$numberOfPosts,'post_type' =>'post' ));
See the link to find out what else you can customize on get_posts. Perhaps you could pull only posts with a given tag or from a given category.
I'm about to finish a wordpress-site with a custom theme and several custom-post-types. Now i wanted to change the permalink settings to %post-name%, to make the url's nicer and this is where the problems start.
I have 3 custom-post-types next to the default post-format: events, galleries, shop. Now when I load the page "events (using the template-events.php, what does a wp_query to get all the events), I get all posts. It basically ignores the defined template and loads the one defined for the posts-page, same happens for the shop-page.
The strange thing is that the gallery page (loading the same kind of template file to do the wp_query) works fine.
When I change back to the default permalink-setting everything works fine...
Thanks for any hint!
here my template-events.php
<?php
/*
Template Name: Events
*/
?>
<?php get_header(); ?>
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$now = strtotime("now");
$args = array(
'post_type' => 'events',
'posts_per_page' => 40,
'post_status' => 'publish',
'meta_key' => '_cmb_date_timestamp',
'orderby' => 'meta_value',
'order' => 'ASC',
'paged' => $paged,
'meta_query' => array(
array(
'key' => '_cmb_date_timestamp',
'value' => $now,
'type' => 'NUMERIC',
'compare' => '>=' )
)
);
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
// posts in the last 30 days
$where .= " AND _cmb_date_timestamp < '" . date('Y-m-d') . "'";
return $where;
}
//add_filter( 'posts_where', 'filter_where' );
$events_query = new WP_Query($args);
if( $events_query->have_posts() ) :
$derLudwig = get_theme_mod( 'eventsHeading', '');
$url = esc_url( get_theme_mod( 'events_image' ) );
echo '<div class="overview-header" style="background-image: url('.$url.');"></div>';
echo '<h2 class="overview">der Ludwig '.$derLudwig.'</h2>';
?>
<div id="filters">
<div id="filterButtons">
<a id="filterOpen" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/sub-navi2.png"/></a>
<a id="filterClose" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/filter-close.png"/></a>
</div>
<?php
/* FILTERS */
$args = array(
'type' => 'events',
'taxonomy' => 'event_category',
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
echo '<div id="categories">';
echo '<h5>Kategorien: </h5>';
echo '<ul>';
foreach ($categories as $category) {
echo '<li>' . $category->name . '</li>';
}
echo '</ul>';
echo '</div>';
?>
Clear
</div>
<!--BEGIN #content -->
<div id="content" class="clearfix">
<?php
echo '<img class="loader" src="'.get_bloginfo('template_url').'/images/loader.gif"/>';
echo '<div id="primary" class="hfeed event-overview">';
while( $events_query->have_posts() ) : $events_query->the_post();
// infos
$time = get_post_meta($post->ID, '_cmb_time', true);
$cdateStamp = get_post_meta($post->ID, '_cmb_date_timestamp');
$monthName = date_i18n('F', $cdateStamp[0]);
$weekdayNumber = date_i18n('j', $cdateStamp[0]);
$weekday = date_i18n('D', $cdateStamp[0]);
$locations = get_the_terms( $post->ID, 'locations' );
$tickets = get_post_meta($post->ID, '_ludwig_events_tickets', true);
$featured = get_post_meta($post->ID, '_ludwig_events_display_featured', true);
$reservation = get_post_meta($post->ID, '_ludwig_events_display_reservation', true);
// grab everything else
$custom_bg = get_post_meta($post->ID, '_zilla_portfolio_display_background', true);
$portfolio_caption = get_post_meta($post->ID, '_zilla_portfolio_caption', true);
?>
<?php
if(!isset($currentMonth) || $currentMonth != $monthName){
?>
<h2 class="<?php echo lcfirst($monthName); ?>"><?php echo $monthName; ?></h2>
<?php
}
$currentMonth = $monthName;
?>
<!--BEGIN .hentry-->
<div id="post-<?php the_ID(); ?>" class="event-small <?php echo lcfirst($monthName); ?>">
<!--BEGIN .entry-content -->
<div class="entry-content">
<div class="eTop">
<span class="dateDay"><?echo $weekdayNumber; ?></span>
<span class="dateMonth"><? _e($monthName, 'ludwig-events'); ?></span>
<span class="dateWeekDay"><? _e($weekday, 'ludwig-events'); ?></span>
</div>
<?php the_post_thumbnail('event-small'); ?>
<div class="eBottom">
<?php the_title('<h3>', '</h3>'); ?>
<span class="eventWo">
<?php
if ( $locations && !is_wp_error( $locations ) ) {
foreach ( $locations as $location ) {
echo $location->name;
}
}
?>
, <?php echo $time; ?>Uhr</span>
<div class="event-buttons">
<div class="inner">
<div class="centerContainer">
<h4>Tickets</h4>
<?php ticketsLink($tickets); ?>
<?php reservationLink($reservation); ?>
</div>
</div>
</div>
</div>
<!--END .entry-content -->
</div>
</div>
<?php endwhile; ?>
<!--END #primary .hfeed-->
</div>
<?php else: ?>
<div id="content" class="nocontent">
<!--BEGIN #post-0-->
<div id="post-0" <?php post_class(); ?>>
<h2 class="entry-title"><?php _e('Keine Events gefunden', 'ludwig') ?></h2>
<!--BEGIN .entry-content-->
<div class="entry-content">
<p><?php _e("Hoppala, das sollte eigentlich nicht passieren", "ludwig") ?></p>
<!--END .entry-content-->
</div>
<!--END #post-0-->
</div>
</div>
<?php endif; ?>
<?php remove_filter( 'posts_where', 'filter_where' ); ?>
<?php get_footer(); ?>
here the working template-gallery.php
<?php
/*
Template Name: Fotos
*/
?>
<?php get_header(); ?>
<?php
//Fix homepage pagination
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
// CHECK THAT THIS ONE ISTN DOWN
/*
$args = array(
'post_type' => 'gallery',
'posts_per_page' => 1,
'post_status' => 'publish',
'orderby' => 'modified',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'gallery_category',
'field' => 'id',
'terms' => array( $term_id ),
'operator' => 'IN'
)
),
'paged' => $paged
);
$sina_query = new WP_Query($args);
$sinaString = '';
if( $posts_query->have_posts() ) :
while( $posts_query->have_posts() ) : $posts_query->the_post();
?>
<?php endwhile; ?>
<?php endif; ?>
*/
$args = array(
'post_type' => 'gallery',
'orderby' => 'modified',
'order' => 'DESC',
'posts_per_page' => 10,
'paged' => $paged
);
$posts_query = new WP_Query($args);
if( $posts_query->have_posts() ) :
$derLudwig = get_theme_mod( 'fotosHeading', '');
$url = esc_url( get_theme_mod( 'fotos_image' ) );
echo '<div class="overview-header" style="background-image: url('.$url.');"></div>';
echo '<h2 class="overview">der Ludwig '.$derLudwig.'</h2>';
?>
<div id="filters">
<div id="filterButtons">
<a id="filterOpen" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/sub-navi2.png"/></a>
<a id="filterClose" class="filterB" href="#"><img src="<?php echo get_bloginfo("template_url"); ?>/images/filter-close.png"/></a>
</div>
<?php
/* FILTERS */
$args = array(
'type' => 'events',
'taxonomy' => 'gallery_category',
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
echo '<div id="categories">';
echo '<h5>Kategorien: </h5>';
echo '<ul>';
foreach ($categories as $category) {
echo '<li>' . $category->name . '</li>';
}
echo '</ul>';
echo '</div>';
?>
Clear
</div>
<!--BEGIN #content -->
<div id="content" class="clearfix">
<?php
echo '<img class="loader" src="'.get_bloginfo('template_url').'/images/loader.gif"/>';
echo '<div id="primary" class="hfeed gallery-overview">';
$counter = 0;
while( $posts_query->have_posts() ) : $posts_query->the_post();
$fotograf = get_post_meta($post->ID, '_ludwig_gallery_fotograf', true);
?>
<?php
if ($counter == 1) {
?>
<div id="post-<?php the_ID(); ?>" class="gallery-grid post-<?php echo $counter++; ?>">
<!--BEGIN .entry-content -->
<div class="entry-content">
<a href="<?php echo get_permalink(); ?>">
<div class="overlayContainer">
<div class="overlay">
<div class="content">
<div class="inner">
<?php
/*
$terms = get_the_terms( $post->ID, 'gallery_category');
if ( $terms && ! is_wp_error( $terms ) ) :
$draught_links = array();
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
*/
?>
<p class="galleryCategories">
<span><?php //echo $on_draught; ?></span>
</p>
<?php //endif; ?>
<h3><?php the_title(); ?></h3>
<p class="fotograf">von<br><span><?php echo $fotograf; ?></span></p>
</div>
</div>
</div>
</div>
<?php the_post_thumbnail('gallery-mid'); ?></a>
</div>
</div>
<?php echo $counter++; ?>
<?php
} else {
?>
<div id="post-<?php the_ID(); ?>" class="gallery-grid post-<?php echo $counter++; ?>">
<!--BEGIN .entry-content -->
<div class="entry-content">
<a href="<?php echo get_permalink(); ?>">
<div class="overlayContainer">
<div class="overlay">
<div class="content">
<div class="inner">
<?php
/*
$terms = get_the_terms( $post->ID, 'gallery_category');
if ( $terms && ! is_wp_error( $terms ) ) :
$draught_links = array();
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
*/
?>
<p class="galleryCategories">
<span><?php //echo $on_draught; ?></span>
</p>
<?php //endif; ?>
<h3><?php the_title(); ?></h3>
<p class="fotograf">von<br><span><?php echo $fotograf; ?></span></p>
</div>
</div>
</div>
</div>
<?php the_post_thumbnail('gallery-mid'); ?></a>
</div>
</div>
<?php } ?>
<?php endwhile; ?>
<!--END .hfeed -->
</div>
<a class="archivlink" href="#">⌸ Archiv</a>
<div class="navigation">
<div class="next-posts"><?php next_posts_link('« Older Entries', $posts_query->max_num_pages) ?></div>
<div class="prev-posts"><?php previous_posts_link('Newer Entries »', $posts_query->max_num_pages) ?></div>
</div>
<?php else: ?>
<div id="content" class="nocontent">
<!--BEGIN #post-0-->
<div id="post-0" <?php post_class(); ?>>
<h2 class="entry-title"><?php _e('Keine Fotos gefunden', 'ludwig') ?></h2>
<!--BEGIN .entry-content-->
<div class="entry-content">
<p><?php _e("Hoppala, das sollte eigentlich nicht passieren", "ludwig") ?></p>
<!--END .entry-content-->
</div>
<!--END #post-0-->
</div>
</div>
<?php endif; ?>
<?php get_footer(); ?>
Hint from me (Since you do not put a code):
Nothing wrong with the permalink. It should be work. I believe what cause this is your code. Please, double check your code and re-install your WordPress, and try again.