Wordpress: Comments: Submitting a comment opens a related post - php

I have a problem with my comments form.
Submitting a comment leads to open a related post.
Here's my comments.php:
<?php
if ( post_password_required() ) :
echo '<h3 class="comments-header">' . __('Password Protected', 'buddypress') . '</h3>';
echo '<p class="alert password-protected">' . __('Enter the password to view comments.', 'buddypress') . '</p>';
return;
endif;
if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
return;
?>
<?php if ( have_comments() ) : ?>
<div id="comments">
<?php
// Only include comments
$numTrackBacks = 0; $numComments = 0;
foreach ( (array)$comments as $comment )
if ( 'comment' != get_comment_type() )
$numTrackBacks++;
else
$numComments++;
?>
<h3 id="comments">
<?php
printf( _n( '1 Kommentar', '%1$s Kommentare', $numComments, 'buddypress' ),
number_format_i18n( $numComments ), '<em>' . get_the_title() . '</em>' );
?>
</h3>
<?php do_action( 'bp_before_blog_comment_list' ) ?>
<ol class="commentlist">
<?php wp_list_comments() ; ?>
</ol><!-- .comment-list -->
<?php do_action( 'bp_after_blog_comment_list' ) ?>
<?php if ( get_option( 'page_comments' ) ) : ?>
<div class="comment-navigation paged-navigation">
<?php paginate_comments_links(); ?>
</div>
<?php endif; ?>
</div><!-- #comments -->
<?php else : ?>
<?php if ( pings_open() && !comments_open() && is_single() ) : ?>
<p class="comments-closed pings-open">
<?php printf( __('Comments are closed, but trackbacks and pingbacks are open.', 'buddypress'), trackback_url( '0' ) ); ?>
</p>
<?php elseif ( !comments_open() && is_single() ) : ?>
<p class="comments-closed">
<?php _e('Keine Kommentare erlaubt.', 'buddypress'); ?>
</p>
<?php endif; ?>
<?php endif; ?>
<?php if ( comments_open() ) : ?>
<div id="respond">
<div class="comment-avatar-box">
<div class="avb">
<?php if ( bp_loggedin_user_id() ) : ?>
<a href="<?php echo bp_loggedin_user_domain() ?>">
<?php echo get_avatar( bp_loggedin_user_id(), 50 ); ?>
</a>
<?php else : ?>
<?php echo get_avatar( 0, 50 ); ?>
<?php endif; ?>
</div>
</div>
<div class="comment-content">
<h3 id="reply" class="comments-header">
<?php comment_form_title( __( 'Leave a Reply', 'buddypress' ), __( 'Leave a Reply to %s', 'buddypress' ), true ); ?>
</h3>
<p id="cancel-comment-reply">
<?php cancel_comment_reply_link( __( 'Click here to cancel reply.', 'buddypress' ) ); ?>
</p>
<?php if ( get_option( 'comment_registration' ) && !$user_ID ) : ?>
<p class="alert">
<?php printf( __('You must be logged in to post a comment.', 'buddypress'), wp_login_url( get_permalink() ) ); ?>
</p>
<?php else : ?>
<?php do_action( 'bp_before_blog_comment_form' ) ?>
<form action="<?php echo site_url( 'wp-comments-post.php' ) ?>" method="post" id="commentform" class="standard-form">
<?php if ( $user_ID ) : ?>
<p class="log-in-out">
<?php printf( __('Logged in as %2$s.', 'buddypress'), bp_loggedin_user_domain(), $user_identity ); ?> <?php _e('Log out →', 'buddypress'); ?>
</p>
<?php else : ?>
<?php $req = get_option( 'require_name_email' ); ?>
<p class="form-author">
<label for="author"><?php _e('Name', 'buddypress'); ?> <?php if ( $req ) : ?><span class="required"><?php _e('*', 'buddypress'); ?></span><?php endif; ?></label>
<input type="text" class="text-input" name="author" id="author" value="<?php echo $comment_author; ?>" size="40" tabindex="1" />
</p>
<p class="form-email">
<label for="email"><?php _e('Email', 'buddypress'); ?> <?php if ( $req ) : ?><span class="required"><?php _e('*', 'buddypress'); ?></span><?php endif; ?></label>
<input type="text" class="text-input" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="40" tabindex="2" />
</p>
<p class="form-url">
<label for="url"><?php _e('Website', 'buddypress'); ?></label>
<input type="text" class="text-input" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="40" tabindex="3" />
</p>
<?php endif; ?>
<p class="form-textarea">
<label for="comment"><?php _e('Comment', 'buddypress'); ?></label>
<textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea>
</p>
<?php do_action( 'bp_blog_comment_form' ) ?>
<p class="form-submit">
<input class="submit-comment button" name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit', 'buddypress'); ?>" />
<?php comment_id_fields(); ?>
</p>
<div class="comment-action">
<?php do_action( 'comment_form', $post->ID ); ?>
</div>
</form>
<?php do_action( 'bp_after_blog_comment_form' ) ?>
<?php endif; ?>
</div><!-- .comment-content -->
</div><!-- #respond -->
<?php endif; ?>
<?php if ( $numTrackBacks ) : ?>
<div id="trackbacks">
<span class="title"><?php the_title() ?></span>
<?php if ( 1 == $numTrackBacks ) : ?>
<h3><?php printf( __( '%d Trackback', 'buddypress' ), $numTrackBacks ) ?></h3>
<?php else : ?>
<h3><?php printf( __( '%d Trackbacks', 'buddypress' ), $numTrackBacks ) ?></h3>
<?php endif; ?>
<ul id="trackbacklist">
<?php foreach ( (array)$comments as $comment ) : ?>
<?php if ( get_comment_type() != 'comment' ) : ?>
<li><h5><?php comment_author_link() ?></h5><em>on <?php comment_date() ?></em></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
An answer would be appreciated
Update:
My single.php:
<?php get_header(); ?>
<!-- LAESST DEN HEADER ERSCHEINEN -->
<div id="main">
<!-- DAS IST DER LOOP! HIER WIRD DER BEFEHL GEGEBEN, DEN INHALT ANZUZEIGEN (ARTIKEL ETC) -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2> <!-- DIESER BEFEHL ZEIGT UND VERLINKT DIE ARTIKEL UEBERSCHRIFT -->
<div class="entry">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<div class="author-box">
<p><?php echo get_avatar( get_the_author_meta( 'user_email' ), '50' ); ?></p>
<p><?php printf( __( 'Geschrieben von %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?> am <?php the_time('j. F Y'); ?> um <?php the_time(); ?></p>
<p> Kategorie(n): <?php the_category(', '); ?> </p>
</div>
<div id="related-posts"
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>3, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
echo '<h3>Das könnte dich auch interessieren</h3><ul>';
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<li><?php the_title(); ?></li>
<?php
}
echo '</ul>';
}
}
?>
</div>
<!--"NEXT POST" BZW "PREVIOUS POST" NAVIGATION -->
<p align="center"><?php next_posts_link('« Ältere Einträge') ?> <?php previous_posts_link('Neuere Einträge »') ?></p>
<?php endif; ?>
<?php comments_template(); ?> <!-- LAESST DAS KOMMENTARFELD ERSCHEINEN -->
</div><!-- main -->
<div id="sidebar">
<?php get_sidebar(); ?>
<!-- LAESST DIE SIDEBAR ERSCHEINEN -->
</div><!-- sidebar -->
<?php get_footer(); ?>
<!-- DIESER BEFEHL LAESST DEN FOOTER ERSCHEINEN -->
But why is it displayed incorrectly?

The only point in your code that could be responsible for your problem, as far as I can see, is at:
<div class="comment-action">
<?php do_action( 'comment_form', $post->ID ); ?>
</div>
$post->ID should hold the id of the current post or be null. If there is a problem with $post, it will be on the page that calls this comments template, single.php probably. You could try changing your current single.php file for the twentyten one and see if that solves the problem. Or post here that single.php file contents so we can check it.
EDIT:
On the single.php file, you have a new query being executed to get the related posts:
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>3, // Number of related posts that will be shown.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
This code is populating the $post variable with each of the related posts found, so once that code is done you will have the $post var holding the last post of the related posts retrieved with that query.
Easiest solution: cut the code for the related posts functionality (everything inside de "related-posts" div, including the opening and closing div tags) and paste it just before the </div><!-- main --> so it doesn't affect the comments or navigation parts.

Related

Buddyboss Group Filter

In the Buddyboss Group Loop are all groups displayed.
I want to add a filter that only groups with a specific categrorie are displayed in the first grid.
I added the comment to the first grid and found out that i can display another grid when
i duplicate the code a second time, but i have the filter problem.
Then i want to add another grid with also a filter to another group categorie.
How can i achieve this?
I dont get it how to add a filter.
<?php
/**
* BuddyBoss - Groups Loop
*
* #since BuddyPress 3.0.0
* #version 3.1.0
*/
bp_nouveau_before_loop(); ?>
<?php if ( bp_get_current_group_directory_type() ) : ?>
<div class="bp-feedback info">
<span class="bp-icon" aria-hidden="true"></span>
<p class="current-group-type"><?php bp_current_group_directory_type_message(); ?></p>
</div>
<?php endif; ?>
<?php $cover_class = bp_disable_group_cover_image_uploads() ? 'bb-cover-disabled' : 'bb-cover-enabled'; ?>
<?php if ( bp_has_groups( bp_ajax_querystring( 'groups' ) ) ) : ?>
<?php bp_nouveau_pagination( 'top' ); ?>
//FIRST GRID ONLY FOR "KOMMISIONEN"
<ul id="groups-list-kommissionen" class="<?php bp_nouveau_loop_classes(); ?> <?php echo $cover_class; ?>">
<?php
while ( bp_groups() ) :
bp_the_group();
?>
<li <?php bp_group_class( array( 'item-entry' ) ); ?> data-bp-item-id="<?php bp_group_id(); ?>" data-bp-item-component="groups">
<div class="list-wrap">
<?php if( !bp_disable_group_cover_image_uploads() ) { ?>
<?php
$group_cover_image_url = bp_attachments_get_attachment( 'url', array(
'object_dir' => 'groups',
'item_id' => bp_get_group_id(),
) );
$default_group_cover = buddyboss_theme_get_option( 'buddyboss_group_cover_default', 'url' );
$group_cover_image_url = $group_cover_image_url ?: $default_group_cover;
?>
<div class="bs-group-cover only-grid-view"><img src="<?php echo $group_cover_image_url; ?>"></div>
<?php } ?>
<?php if ( ! bp_disable_group_avatar_uploads() ) : ?>
<div class="item-avatar">
<?php bp_group_avatar( bp_nouveau_avatar_args() ); ?>
<div class="groups-loop-buttons only-grid-view">
<?php bp_nouveau_groups_loop_buttons(); ?>
</div>
</div>
<?php endif; ?>
<div class="item">
<div class="item-block">
<h2 class="list-title groups-title"><?php bp_group_link(); ?></h2>
<?php if ( bp_nouveau_group_has_meta() ) : ?>
<p class="item-meta group-details only-list-view"><?php bp_nouveau_group_meta(); ?></p>
<p class="item-meta group-details only-grid-view"><?php
$meta = bp_nouveau_get_group_meta();
echo $meta['status']; ?>
</p>
<?php endif; ?>
<p class="last-activity item-meta">
<?php
printf(
/* translators: %s = last activity timestamp (e.g. "active 1 hour ago") */
__( 'active %s', 'buddyboss-theme' ),
bp_get_group_last_active()
);
?>
</p>
</div>
<div class="item-desc group-item-desc only-list-view"><?php bp_group_description_excerpt( false , 150 ) ?></div>
<?php bp_nouveau_groups_loop_item(); ?>
<div class="groups-loop-buttons footer-button-wrap"><?php bp_nouveau_groups_loop_buttons(); ?></div>
<div class="group-members-wrap only-grid-view">
<?php echo buddyboss_theme()->buddypress_helper()->group_members( bp_get_group_id(), array( 'member', 'mod', 'admin' ) ); ?>
</div>
</div>
</div>
</li>
<?php endwhile; ?>
<?php bp_nouveau_pagination( 'bottom' ); ?>
<?php else : ?>
<?php bp_nouveau_user_feedback( 'groups-loop-none' ); ?>
<?php endif; ?>
<?php
bp_nouveau_after_loop();
Okay i found the answer by trying all possible ways.
Here is the solution code.
<?php
/**
* BuddyBoss - Groups Loop
*
* #since BuddyPress 3.0.0
* #version 3.1.0
*/
bp_nouveau_before_loop(); ?>
<?php if ( bp_get_current_group_directory_type() ) : ?>
<div class="bp-feedback info">
<span class="bp-icon" aria-hidden="true"></span>
<p class="current-group-type"><?php bp_current_group_directory_type_message(); ?></p>
</div>
<?php endif; ?>
<?php $cover_class = bp_disable_group_cover_image_uploads() ? 'bb-cover-disabled' : 'bb-cover-enabled'; ?>
<?php if ( bp_has_groups( 'group_type=kommission' ) ) : ?>
<?php bp_nouveau_pagination( 'top' ); ?>
<ul id="groups-list-kommissionen" class="<?php bp_nouveau_loop_classes(); ?> <?php echo $cover_class; ?>">
<?php
while ( bp_groups() ) :
bp_the_group();
?>
<li <?php bp_group_class( array( 'item-entry' ) ); ?> data-bp-item-id="<?php bp_group_id(); ?>" data-bp-item-component="groups">
<div class="list-wrap">
<?php if( !bp_disable_group_cover_image_uploads() ) { ?>
<?php
$group_cover_image_url = bp_attachments_get_attachment( 'url', array(
'object_dir' => 'groups',
'item_id' => bp_get_group_id(),
) );
$default_group_cover = buddyboss_theme_get_option( 'buddyboss_group_cover_default', 'url' );
$group_cover_image_url = $group_cover_image_url ?: $default_group_cover;
?>
<div class="bs-group-cover only-grid-view"><img src="<?php echo $group_cover_image_url; ?>"></div>
<?php } ?>
<?php if ( ! bp_disable_group_avatar_uploads() ) : ?>
<div class="item-avatar">
<?php bp_group_avatar( bp_nouveau_avatar_args() ); ?>
<div class="groups-loop-buttons only-grid-view">
<?php bp_nouveau_groups_loop_buttons(); ?>
</div>
</div>
<?php endif; ?>
<div class="item">
<div class="item-block">
<h2 class="list-title groups-title"><?php bp_group_link(); ?></h2>
<?php if ( bp_nouveau_group_has_meta() ) : ?>
<p class="item-meta group-details only-list-view"><?php bp_nouveau_group_meta(); ?></p>
<p class="item-meta group-details only-grid-view"><?php
$meta = bp_nouveau_get_group_meta();
echo $meta['status']; ?>
</p>
<?php endif; ?>
<p class="last-activity item-meta">
<?php
printf(
/* translators: %s = last activity timestamp (e.g. "active 1 hour ago") */
__( 'active %s', 'buddyboss-theme' ),
bp_get_group_last_active()
);
?>
</p>
</div>
<div class="item-desc group-item-desc only-list-view"><?php bp_group_description_excerpt( false , 150 ) ?></div>
<?php bp_nouveau_groups_loop_item(); ?>
<div class="groups-loop-buttons footer-button-wrap"><?php bp_nouveau_groups_loop_buttons(); ?></div>
<div class="group-members-wrap only-grid-view">
<?php echo buddyboss_theme()->buddypress_helper()->group_members( bp_get_group_id(), array( 'member', 'mod', 'admin' ) ); ?>
</div>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php bp_nouveau_pagination( 'bottom' ); ?>
<?php else : ?>
<?php bp_nouveau_user_feedback( 'groups-loop-none' ); ?>
<?php endif; ?>
<?php if ( bp_has_groups( 'group_type=task-force' ) ) : ?>
<?php bp_nouveau_pagination( 'top' ); ?>
<ul id="groups-list-taskForces" class="<?php bp_nouveau_loop_classes(); ?> <?php echo $cover_class; ?>">
<?php
while ( bp_groups() ) :
bp_the_group();
?>
<li <?php bp_group_class( array( 'item-entry' ) ); ?> data-bp-item-id="<?php bp_group_id(); ?>" data-bp-item-component="groups">
<div class="list-wrap">
<?php if( !bp_disable_group_cover_image_uploads() ) { ?>
<?php
$group_cover_image_url = bp_attachments_get_attachment( 'url', array(
'object_dir' => 'groups',
'item_id' => bp_get_group_id(),
) );
$default_group_cover = buddyboss_theme_get_option( 'buddyboss_group_cover_default', 'url' );
$group_cover_image_url = $group_cover_image_url ?: $default_group_cover;
?>
<div class="bs-group-cover only-grid-view"><img src="<?php echo $group_cover_image_url; ?>"></div>
<?php } ?>
<?php if ( ! bp_disable_group_avatar_uploads() ) : ?>
<div class="item-avatar">
<?php bp_group_avatar( bp_nouveau_avatar_args() ); ?>
<div class="groups-loop-buttons only-grid-view">
<?php bp_nouveau_groups_loop_buttons(); ?>
</div>
</div>
<?php endif; ?>
<div class="item">
<div class="item-block">
<h2 class="list-title groups-title"><?php bp_group_link(); ?></h2>
<?php if ( bp_nouveau_group_has_meta() ) : ?>
<p class="item-meta group-details only-list-view"><?php bp_nouveau_group_meta(); ?></p>
<p class="item-meta group-details only-grid-view"><?php
$meta = bp_nouveau_get_group_meta();
echo $meta['status']; ?>
</p>
<?php endif; ?>
<p class="last-activity item-meta">
<?php
printf(
/* translators: %s = last activity timestamp (e.g. "active 1 hour ago") */
__( 'active %s', 'buddyboss-theme' ),
bp_get_group_last_active()
);
?>
</p>
</div>
<div class="item-desc group-item-desc only-list-view"><?php bp_group_description_excerpt( false , 150 ) ?></div>
<?php bp_nouveau_groups_loop_item(); ?>
<div class="groups-loop-buttons footer-button-wrap"><?php bp_nouveau_groups_loop_buttons(); ?></div>
<div class="group-members-wrap only-grid-view">
<?php echo buddyboss_theme()->buddypress_helper()->group_members( bp_get_group_id(), array( 'member', 'mod', 'admin' ) ); ?>
</div>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<?php bp_nouveau_pagination( 'bottom' ); ?>
<?php else : ?>
<?php bp_nouveau_user_feedback( 'groups-loop-none' ); ?>
<?php endif; ?>
<?php
bp_nouveau_after_loop();

Editing User Profile Content in BuddyBoss and/or BuddyPress

I'm trying to remove 'Notifications', 'Groups', 'Messages', & 'Settngs' from user profiles.
How do I go about removing them?
Check out below:
<?php do_action( 'bp_before_profile_edit_content' );
if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) :
while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
<form action="<?php bp_the_profile_group_edit_form_action(); ?>" method="post" id="profile-edit-form" class="standard-form <?php bp_the_profile_group_slug(); ?>">
<?php do_action( 'bp_before_profile_field_content' ); ?>
<h4><?php printf( __( "Editing '%s' Profile Group", "buddypress" ), bp_get_the_profile_group_name() ); ?></h4>
<ul class="button-nav">
<?php bp_profile_group_tabs(); ?>
</ul>
<div class="clear"></div>
<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
<div<?php bp_field_css_class( 'editfield' ); ?>>
<?php
$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
$field_type->edit_field_html();
do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
?>
<?php if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <?php _e( 'Change', 'buddypress' ); ?>
</p>
<div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
<fieldset>
<legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
<?php bp_profile_visibility_radio_buttons() ?>
</fieldset>
<a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
</div>
<?php else : ?>
<div class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
</div>
<?php endif ?>
<p class="description"><?php bp_the_profile_field_description(); ?></p>
</div>
<?php do_action( 'bp_custom_profile_edit_fields' ); ?>
<?php endwhile; ?>
<?php do_action( 'bp_after_profile_field_content' ); ?>
<div class="submit">
<input type="submit" name="profile-group-edit-submit" id="profile-group-edit-submit" value="<?php esc_attr_e( 'Save Changes', 'buddypress' ); ?> " />
</div>
<input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids(); ?>" />
<?php wp_nonce_field( 'bp_xprofile_edit' ); ?>
</form>
<?php endwhile; endif; ?>
<?php do_action( 'bp_after_profile_edit_content' ); ?>
Try:
function evin_remove_nav() {
bp_core_remove_nav_item( 'messages' );
//etc
}
add_action( 'bp_ready', 'evin_remove_nav', 10 );

Add pagination to this Wordpress Home

I Guys! I'm working on a pagination for this theme homepage. The original code is:
<?php
/**
Blog
**/
$display_count = get_theme_mod('wpex_home_blog_count', '30');
$wpex_query = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => $display_count,
'no_found_rows' => true,
)
);
if ( $wpex_query->posts && '0' != $display_count ) { ?>
<div id="homepage-blog" class="clr">
<h2 class="heading"><span><?php _e( 'From The Blog', 'wpex' ); ?></span></h2>
<?php $wpex_count=0; ?>
<?php foreach( $wpex_query->posts as $post ) : setup_postdata( $post ); ?>
<?php $wpex_count++; ?>
<article class="recent-blog-entry clr col span_1_of_3 col-<?php echo $wpex_count; ?>">
<?php
// Display post thumbnail
if ( has_post_thumbnail() ) { ?>
<div class="recent-blog-entry-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>">
<img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" />
</a>
</div><!-- .recent-blog-entry-thumbnail -->
<?php } ?>
<header>
<h3 class="recent-blog-entry-title"><?php the_title(); ?></h3>
<?php
// Display post meta details
wpex_post_meta() ;?>
</header>
<div class="recent-blog-entry-content entry clr">
<?php wpex_excerpt( 18, false ); ?>
</div><!-- .recent-blog-entry-content -->
</article><!-- .recent-blog -->
<?php if ( $wpex_count == '3' ) { ?>
<?php $wpex_count=0; ?>
<?php } ?>
<?php endforeach; ?>
</div><!-- #homepage-portfolio -->
<?php } ?>
What I did is, I changed it to
<div id="homepage-blog" class="clr">
<h2 class="heading"><span><?php _e( 'From The Blog', 'wpex' ); ?></span></h2>
<?php $wpex_count=0; ?>
<?php
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('showposts=4' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php $wpex_count++; ?>
<article class="recent-blog-entry clr col span_1_of_3 col-<?php echo $wpex_count; ?>">
<?php
// Display post thumbnail
if ( has_post_thumbnail() ) { ?>
<div class="recent-blog-entry-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>">
<img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" />
</a>
</div><!-- .recent-blog-entry-thumbnail -->
<?php } ?>
<header>
<h3 class="recent-blog-entry-title"><?php the_title(); ?></h3>
<ul class="post-meta clr">
<li class="meta-date">
<?php _e('Posted on','wpex'); ?>
<span class="meta-date-text"><?php echo get_the_date(); ?></span>
</li>
</ul>
</header>
<div class="recent-blog-entry-content entry clr">
<?php wpex_excerpt( 18, false ); ?>
</div><!-- .recent-blog-entry-content -->
</article><!-- .recent-blog -->
<?php if ( $wpex_count == '3' ) { ?>
<?php $wpex_count=0; ?>
<?php } ?>
<?php endwhile; ?>
</div>
<?php wp_pagenavi();?>
<?php wp_reset_postdata(); ?>
</article>
This seems to work on the first page, but when i go to page 2, it gives an copy after copy after copy of the whole page, like an infinate page one. That's not how it should work.
Any ideas what goes wrong here? Does this make any sense to you?
EDIT:
I tried the following. Right now the first page looks good, but when i press the second page on the pagination, it outputs the same as the first.
<?php
$args = array(
'paged' => (get_query_var('paged') ? get_query_var('paged') : 1),
'posts_per_page' => 4
);
query_posts($args);
?>
<div id="homepage-blog" class="clr">
<h2 class="heading"><span><?php _e( 'From The Blog', 'wpex' ); ?></span></h2>
<?php $wpex_count=0; ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php $wpex_count++; ?>
<article class="recent-blog-entry clr col span_1_of_3 col-<?php echo $wpex_count; ?>">
<?php
// Display post thumbnail
if ( has_post_thumbnail() ) { ?>
<div class="recent-blog-entry-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>">
<img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" />
</a>
</div><!-- .recent-blog-entry-thumbnail -->
<?php } ?>
<header>
<h3 class="recent-blog-entry-title"><?php the_title(); ?></h3>
<ul class="post-meta clr">
<li class="meta-date"><?php _e('Posted on','wpex'); ?> <span class="meta-date-text"><?php echo get_the_date(); ?></span> </li>
</ul>
</header>
<div class="recent-blog-entry-content entry clr">
<?php wpex_excerpt( 18, false ); ?>
</div><!-- .recent-blog-entry-content -->
</article><!-- .recent-blog -->
<?php if ( $wpex_count == '3' ) { ?>
<?php $wpex_count=0; ?>
<?php } ?>
<?php endwhile; ?>
<?php wp_pagenavi();?>
</div><!-- #homepage-portfolio -->
<?php endif; ?>
<?php wp_reset_query(); ?>
</article><!-- #post -->
<?php endwhile; ?>
Whole original code:
<div id="primary" class="content-area clr">
<div id="content" class="site-content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<article class="homepage-wrap clr">
<?php
/**
Post Content
**/ ?>
<?php if ( get_the_content() !== '' ) { ?>
<div id="homepage-content" class="entry clr">
<?php the_content(); ?>
</div><!-- .entry-content -->
<?php } ?>
<?php
/**
Features
**/
$wpex_query = new WP_Query(
array(
'order' => 'ASC',
'orderby' => 'menu_order',
'post_type' => 'features',
'posts_per_page' => '-1',
'no_found_rows' => true,
)
);
if ( $wpex_query->posts ) { ?>
<div id="homepage-features" class="clr">
<?php $wpex_count=0; ?>
<?php foreach( $wpex_query->posts as $post ) : setup_postdata( $post ); ?>
<?php $wpex_count++; ?>
<?php get_template_part( 'content-features', get_post_format() ); ?>
<?php if ( $wpex_count == '4' ) { ?>
<?php $wpex_count=0; ?>
<?php } ?>
<?php endforeach; ?>
</div><!-- #homepage-features -->
<?php } ?>
<?php wp_reset_postdata(); ?>
<?php
/**
Portfolio
**/
$display_count = get_theme_mod('wpex_home_portfolio_count', '8');
$wpex_query = new WP_Query(
array(
'post_type' => 'portfolio',
'posts_per_page' => $display_count,
'no_found_rows' => true,
'tax_query' => wpex_home_portfolio_taxonomy(),
)
);
if ( $wpex_query->posts && '0' != $display_count ) { ?>
<div id="homepage-portfolio" class="clr">
<h2 class="heading"><span><?php _e( 'Recent Work', 'wpex' ); ?></span></h2>
<?php $wpex_count=0; ?>
<?php foreach( $wpex_query->posts as $post ) : setup_postdata( $post ); ?>
<?php $wpex_count++; ?>
<?php get_template_part( 'content-portfolio', get_post_format() ); ?>
<?php if ( $wpex_count == '4' ) { ?>
<?php $wpex_count=0; ?>
<?php } ?>
<?php endforeach; ?>
</div><!-- #homepage-portfolio -->
<?php } ?>
<?php wp_reset_postdata(); ?>
<?php
/**
Blog
**/
$display_count = get_theme_mod('wpex_home_blog_count', '30');
$wpex_query = new WP_Query(
array(
'post_type' => 'post',
'posts_per_page' => $display_count,
'no_found_rows' => true,
)
);
if ( $wpex_query->posts && '0' != $display_count ) { ?>
<div id="homepage-blog" class="clr">
<h2 class="heading"><span><?php _e( 'From The Blog', 'wpex' ); ?></span></h2>
<?php $wpex_count=0; ?>
<?php foreach( $wpex_query->posts as $post ) : setup_postdata( $post ); ?>
<?php $wpex_count++; ?>
<article class="recent-blog-entry clr col span_1_of_3 col-<?php echo $wpex_count; ?>">
<?php
// Display post thumbnail
if ( has_post_thumbnail() ) { ?>
<div class="recent-blog-entry-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>">
<img src="<?php echo wpex_get_featured_img_url(); ?>" alt="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>" />
</a>
</div><!-- .recent-blog-entry-thumbnail -->
<?php } ?>
<header>
<h3 class="recent-blog-entry-title"><?php the_title(); ?></h3>
<?php
// Display post meta details
wpex_post_meta() ;?>
</header>
<div class="recent-blog-entry-content entry clr">
<?php wpex_excerpt( 18, false ); ?>
</div><!-- .recent-blog-entry-content -->
</article><!-- .recent-blog -->
<?php if ( $wpex_count == '3' ) { ?>
<?php $wpex_count=0; ?>
<?php } ?>
<?php endforeach; ?>
</div><!-- #homepage-portfolio -->
<?php } ?>
<?php wp_reset_postdata(); ?>
</article><!-- #post -->
<?php comments_template(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
Try declaring $paged outside, and call this in the query_posts
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 4
);
query_posts($args . '&paged=' . $paged);
I might have found an answer for this myself, apparently it's different when you use pagination on the frontpage. I used this and it seems to be working!:
if( is_front_page() ){
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
} else {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
}

BuddyPress registration form shortcode

I'm trying to get the registration form for BuddyPress.
I searching for a shortcode or just php code.
I've try to copy the field in template's of buddypress plugin. But it's dosen't work.
Here is the code I place in a custom post type.
<div id="buddypress">
<?php do_action( 'bp_before_register_page' ); ?>
<div class="page" id="register-page">
<form action="" name="signup_form" id="signup_form" class="standard-form" method="post" enctype="multipart/form-data">
<?php if ( 'registration-disabled' == bp_get_current_signup_step() ) : ?>
<?php do_action( 'template_notices' ); ?>
<?php do_action( 'bp_before_registration_disabled' ); ?>
<p><?php _e( 'User registration is currently not allowed.', 'buddypress' ); ?></p>
<?php do_action( 'bp_after_registration_disabled' ); ?>
<?php endif; // registration-disabled signup setp ?>
<?php if ( 'request-details' == bp_get_current_signup_step() ) : ?>
<?php do_action( 'template_notices' ); ?>
<p><?php _e( 'Registering for this site is easy. Just fill in the fields below, and we\'ll get a new account set up for you in no time.', 'buddypress' ); ?></p>
<?php do_action( 'bp_before_account_details_fields' ); ?>
<div class="register-section" id="basic-details-section">
<?php /***** Basic Account Details ******/ ?>
<h4><?php _e( 'Account Details', 'buddypress' ); ?></h4>
<label for="signup_username"><?php _e( 'Username', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
<?php do_action( 'bp_signup_username_errors' ); ?>
<input type="text" name="signup_username" id="signup_username" value="<?php bp_signup_username_value(); ?>" />
<label for="signup_email"><?php _e( 'Email Address', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
<?php do_action( 'bp_signup_email_errors' ); ?>
<input type="text" name="signup_email" id="signup_email" value="<?php bp_signup_email_value(); ?>" />
<label for="signup_password"><?php _e( 'Choose a Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
<?php do_action( 'bp_signup_password_errors' ); ?>
<input type="password" name="signup_password" id="signup_password" value="" class="password-entry" />
<div id="pass-strength-result"></div>
<label for="signup_password_confirm"><?php _e( 'Confirm Password', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
<?php do_action( 'bp_signup_password_confirm_errors' ); ?>
<input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" class="password-entry-confirm" />
<?php do_action( 'bp_account_details_fields' ); ?>
</div><!-- #basic-details-section -->
<?php do_action( 'bp_after_account_details_fields' ); ?>
<?php /***** Extra Profile Details ******/ ?>
<?php if ( bp_is_active( 'xprofile' ) ) : ?>
<?php do_action( 'bp_before_signup_profile_fields' ); ?>
<div class="register-section" id="profile-details-section">
<h4><?php _e( 'Profile Details', 'buddypress' ); ?></h4>
<?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
<?php if ( bp_is_active( 'xprofile' ) ) : if ( bp_has_profile( array( 'profile_group_id' => 1, 'fetch_field_data' => false ) ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
<div<?php bp_field_css_class( 'editfield' ); ?>>
<?php
$field_type = bp_xprofile_create_field_type( bp_get_the_profile_field_type() );
$field_type->edit_field_html();
do_action( 'bp_custom_profile_edit_fields_pre_visibility' );
if ( bp_current_user_can( 'bp_xprofile_change_field_visibility' ) ) : ?>
<p class="field-visibility-settings-toggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?> <?php _ex( 'Change', 'Change profile field visibility level', 'buddypress' ); ?>
</p>
<div class="field-visibility-settings" id="field-visibility-settings-<?php bp_the_profile_field_id() ?>">
<fieldset>
<legend><?php _e( 'Who can see this field?', 'buddypress' ) ?></legend>
<?php bp_profile_visibility_radio_buttons() ?>
</fieldset>
<a class="field-visibility-settings-close" href="#"><?php _e( 'Close', 'buddypress' ) ?></a>
</div>
<?php else : ?>
<p class="field-visibility-settings-notoggle" id="field-visibility-settings-toggle-<?php bp_the_profile_field_id() ?>">
<?php printf( __( 'This field can be seen by: <span class="current-visibility-level">%s</span>', 'buddypress' ), bp_get_the_profile_field_visibility_level_label() ) ?>
</p>
<?php endif ?>
<?php do_action( 'bp_custom_profile_edit_fields' ); ?>
<p class="description"><?php bp_the_profile_field_description(); ?></p>
</div>
<?php endwhile; ?>
<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_field_ids(); ?>" />
<?php endwhile; endif; endif; ?>
<?php do_action( 'bp_signup_profile_fields' ); ?>
</div><!-- #profile-details-section -->
<?php do_action( 'bp_after_signup_profile_fields' ); ?>
<?php endif; ?>
<?php if ( bp_get_blog_signup_allowed() ) : ?>
<?php do_action( 'bp_before_blog_details_fields' ); ?>
<?php /***** Blog Creation Details ******/ ?>
<div class="register-section" id="blog-details-section">
<h4><?php _e( 'Blog Details', 'buddypress' ); ?></h4>
<p><input type="checkbox" name="signup_with_blog" id="signup_with_blog" value="1"<?php if ( (int) bp_get_signup_with_blog_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes, I\'d like to create a new site', 'buddypress' ); ?></p>
<div id="blog-details"<?php if ( (int) bp_get_signup_with_blog_value() ) : ?>class="show"<?php endif; ?>>
<label for="signup_blog_url"><?php _e( 'Blog URL', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
<?php do_action( 'bp_signup_blog_url_errors' ); ?>
<?php if ( is_subdomain_install() ) : ?>
http:// <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value(); ?>" /> .<?php bp_signup_subdomain_base(); ?>
<?php else : ?>
<?php echo home_url( '/' ); ?> <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value(); ?>" />
<?php endif; ?>
<label for="signup_blog_title"><?php _e( 'Site Title', 'buddypress' ); ?> <?php _e( '(required)', 'buddypress' ); ?></label>
<?php do_action( 'bp_signup_blog_title_errors' ); ?>
<input type="text" name="signup_blog_title" id="signup_blog_title" value="<?php bp_signup_blog_title_value(); ?>" />
<span class="label"><?php _e( 'I would like my site to appear in search engines, and in public listings around this network.', 'buddypress' ); ?></span>
<?php do_action( 'bp_signup_blog_privacy_errors' ); ?>
<label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_public" value="public"<?php if ( 'public' == bp_get_signup_blog_privacy_value() || !bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes', 'buddypress' ); ?></label>
<label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_private" value="private"<?php if ( 'private' == bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'No', 'buddypress' ); ?></label>
<?php do_action( 'bp_blog_details_fields' ); ?>
</div>
</div><!-- #blog-details-section -->
<?php do_action( 'bp_after_blog_details_fields' ); ?>
<?php endif; ?>
<?php do_action( 'bp_before_registration_submit_buttons' ); ?>
<div class="submit">
<input type="submit" name="signup_submit" id="signup_submit" value="<?php esc_attr_e( 'Complete Sign Up', 'buddypress' ); ?>" />
</div>
<?php do_action( 'bp_after_registration_submit_buttons' ); ?>
<?php wp_nonce_field( 'bp_new_signup' ); ?>
<?php endif; // request-details signup step ?>
<?php if ( 'completed-confirmation' == bp_get_current_signup_step() ) : ?>
<?php do_action( 'template_notices' ); ?>
<?php do_action( 'bp_before_registration_confirmed' ); ?>
<?php if ( bp_registration_needs_activation() ) : ?>
<p><?php _e( 'You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.', 'buddypress' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have successfully created your account! Please log in using the username and password you have just created.', 'buddypress' ); ?></p>
<?php endif; ?>
<?php do_action( 'bp_after_registration_confirmed' ); ?>
<?php endif; // completed-confirmation signup step ?>
<?php do_action( 'bp_custom_signup_steps' ); ?>
</form>
</div>
<?php do_action( 'bp_after_register_page' ); ?>
</div><!-- #buddypress -->
Are you not happy with the default form that shows up? When buddypress is installed it creates a few pages on your site. If you navigate to Settings->BuddyPress ->pages, you will see that the register page is pointing to... well Register :) There should be a "Register" page present in your All Pages. This is installed by buddypress
By Default, buddypress installs a Register page at : www.yoursite.com/Register
Open it while you are not log in and you can see the Registration Form.
Go to buddypress plugin template folder:
wp-content\plugins\buddypress\bp-templates\bp-legacy\buddypress
Copy the buddypress folder and paste it into your theme's root.
Now go to:
wp-content\YOURTHEME\buddypress\bp-templates\bp-legacy\buddypress\members folder and you will find a register.php file. You can work with it.

Wordpress Blog page only showing one post

Im having an issue with a theme i've been customizing. My blog post only shows ( 1 ) post and i cant seem to fix the issue in Admin > Reading > Blog pages show at most. The Value only stays at "1" even after save. The code i have here is in the Loop.php
<?php ?>
<article class="primary-content">
<?php $firstClass='first-post' ; ?>
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if ( ! have_posts() ) : ?>
<article role="main" class="the-content">
<h1><?php _e( '404 - I'm sorry but the page can't be found' ); ?></h1>
<p>Please try searching again or head back to the homepage.</p>
</article>
<?php endif; ?>
<?php ?>
<?php if (is_home()): ?>
<h1>
<?php if ( is_day() ) : ?><?php printf( __( '<span>Daily Archive</span> %s' ), get_the_date() ); ?>
<?php elseif ( is_month() ) : ?><?php printf( __( '<span>Monthly Archive</span> %s' ), get_the_date('F Y') ); ?>
<?php elseif ( is_year() ) : ?><?php printf( __( '<span>Yearly Archive</span> %s' ), get_the_date('Y') ); ?>
<?php elseif ( is_category() ) : ?><?php echo single_cat_title(); ?>
<?php elseif ( is_search() ) : ?><?php printf( __( 'Search Results for: %s' ), '<span>' . get_search_query() . '</span>' ); ?>
<?php elseif ( is_home() ) : ?>Blog<?php else : ?>
<?php endif; ?>
</h1>
<?php endif; ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php /* How to display standard posts and search results */ ?>
<article class="article-archive <?php echo $firstClass; ?>" id="post-<?php the_ID(); ?>">
<?php $firstClass="" ; ?>
<?php ?>
<?php if (is_front_page()) { ?>
<div class="home-summary">
<?php } else { ?>
<div class="entry-summary">
<?php } ?>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( '%s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php the_post_thumbnail( 'flozo-thumb');?>
</a>
<?php if (is_front_page()) { ?>
<h1><?php the_title(); ?></h1>
<?php } else { ?>
<h2><?php the_title(); ?></h2>
<?php } ?>
<?php the_excerpt(); ?>
<?php if ( is_home() ) : ?>
<p class="entry-meta">
<time datetime="<?php the_time('l, F jS, Y') ?>" pubdate>
<?php the_time( 'l jS F Y') ?>
</time>
</p>
<?php endif; ?>
</div>
</article>
<?php /*?>
<?php comments_template( '', true ); ?>
<?php */?>
<?php endwhile; // End the loop. Whew. ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div class="navigation">
<div class="nav-previous">
<?php next_posts_link( __( 'Older posts' ) ); ?>
</div>
<div class="nav-next">
<?php previous_posts_link( __( 'Newer posts' ) ); ?>
</div>
</div>
<!-- #nav-below -->
<?php endif; ?>
</article>
Any and all help with be greatly appreciated! Sorry if this was posted already.
L

Categories