Hello im running the wishlist member plugin in my wordpress site but it seems that it doesnt block the archives pages. What Im trying to do is use this 2 shortcodes so it blocks the content the it shows in the archive page. How can I add this open and close shortcodes to the php file below:
[wlm_ismember] [/wlm_ismember]
This is the php code im using to put the shortcodes
<?php echo do_shortcode('[shortcode]');?
This is the file im working with, I want to put the [wlm_ismember] shortcode above <article <?php post_class(); ?>>, and [/wlm_ismember] below </article> so the article doesnt show.
<?php /* Loop Template used for index/archive/search */
$options = get_option('mh_options');
$excerpt_length = empty($options['excerpt_length']) ? '125' : $options['excerpt_length'];
?>
<?php echo do_shortcode('[wlm_ismember]');?>
<article <?php post_class(); ?>>
<div class="loop-wrap clearfix">
<div class="loop-thumb">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) { the_post_thumbnail('loop'); } ?>
</a>
</div>
<header class="loop-data">
<h3 class="loop-title"><?php the_title(); ?></h3>
<p class="meta"><?php $date = get_the_date(); echo $date; ?> // <?php comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh')); ?></p>
</header>
<?php the_content(); ?>
</div>
</article>
Related
I am new to wordpress theme development and currently building building my first one from scratch, I have hit an issue with adding comments with blog posts.
I have the loop the that returns each post:
<div class="eachPost">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>"><?php
the_title();?></a></h2>
<p class="entry-meta">by <?php the_author_meta('first_name'); ?>
<?php the_author_meta('last_name'); ?> in <?php the_category(", ")
?></p>
<p class='right'><a class='comments-count' href='<?php the_permalink() ?>'><?php comments_number('0', '1', '%')
?></a></p>
<?php comments_template(); ?>
</article>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<p><?php the_content(__('(more...)')); ?></p>
<hr> <?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
</div>
I believe that I need to call the function:
<?php comments_template(); ?>
but adding this to the code has no effect.
I have comments.php and comment-template.php in the same folder as the file and believe that I need to include these in the page as follows
<?php get_template_part('comments.php'); ?>
<?php get_template_part('comments_template.php'); ?>
Using in config
<?php define('WP_DEBUG', true);?>
<?php define('WP_DEBUG_LOG', true);?>
<?php define('WP_DEBUG_DISPLAY', true);?>
Create no error in logs or info.
In a clean build template how do you include comments under posts?
The comments.php needs to be inside the Template root folder, please take a look at the Wordpress Codex http://codex.wordpress.org/Function_Reference/comments_template
If you want to have it somewhere else, here's the Wordpress recommendation:
The path to the file used for an alternative comments template should
be relative to the current theme root directory, and include any
subfolders. So if the custom comments template is in a folder inside
the theme, it may look like this when called:
<?php comments_template( '/custom-templates/alternative-comments.php' ); ?>
You see no errors because there's no mistake there. The system is calling a function that should load a file that if it doesn't exist, no error is thrown.
New to php and the loop process. Is it okay to have html markups inside the loop? Also I often see something like <?php get_template_part( 'content', get_post_format() ); ?> or a more complicated version in other themes. Should I house the loop in a separate php file and call it in my posts page?
I just want to make sure that my loop follows the "wordpress rules" and does not look out of the norm. Here is my current loop code that does function properly:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a></h2>
<p>
Published on <?php the_time('M j, Y'); ?> <br>
</p>
<p><em>
by <?php the_author(', '); ?> in <?php the_category(', '); ?> | <?php comments_number(); ?><br>
</em></p>
<?php echo get_the_post_thumbnail($page->ID, 'home-thumb'); ?>
<br>
<p><?php the_content(); ?></p>
<hr>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
<?php else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
It is ok to use markups in the loop, in fact most themes are done that way.
Functions like are just used for reusable code.
get_template_part( 'content', get_post_format() );
If you are going to use that loop elsewhere, separate it into another file. If not, keep it in the same file.
I have a couple of posts that have YouTube videos embedded in them. I only want the videos to show up on the full version of the post. On the category page that lists the posts, I don't want the video to appear.
Here is the site: http://tsa-watch.com/
and the full version of the post:
http://tsa-watch.com/2013/03/25/tsa-makes-double-amputee-marine-remove-prosthetic-legs-during-screening/
Here is a bit of code I use in functions.php to remove the first image from a post ONLY if it is listed on a category page:
function remove_first_image ($content) {
if (is_category()) {
$content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
$content = preg_replace("/<object[^>]+>/i", "", $content, 1);
} return $content;
}
add_filter('the_content', 'remove_first_image');
Also, here is the loop that I am using on my index.php and category.php files:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="votes" style="min-width:60px"><strong>VOTES:</strong><?php wdpv_vote(false); ?></div>
<div class="alignleft" style="max-width:590px">
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a></h2>
<div class="byline"><?php the_time('F jS, Y') ?> by <?php the_author() ?> in <?php the_category(', ') ?> <strong>:</strong> <?php comments_number( 'No Comments', '1 Comment', '% Comments' ); ?></div>
<div class="excerpt">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail(array(115,115));
}
?>
<?php the_content('Read more »'); ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<h1>Not Found</h1>
<p><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php endif; ?>
Any help would be appreciated...
This is a WordPress site I believe?
If so you need to look at editing the theme template file that is responsible for showing the preview of your post on the category pages and remove the section where it is showing images/videos from the post.
Unfortunately not knowing what theme it is you are using or what the file names are called it's hard to tell but look for a page template which has the word home or categories in it or open up the category.php from within your activated theme folder if you have them to see if you can find something related to this and comment it out to see if it fixes it.
Also try adding the following inside your custom function:
$content = preg_replace("/<embed[^>]+>/i", "", $content, 1);
Our blog page is supposed to look something like this: http://livedemo00.template-help.com/wordpress_33821/?page_id=174
However it ends up looking like this - completely empty!
This is despite the fact that the page theme is set correctly and the template file contains the following code:
<?php
/**
* Template Name: Blog
*/
get_header(); ?>
<div class="box clearfix color2">
<div id="content" class="three_fourth">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=5'.'&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<h2><?php the_title(); ?></h2>
<div class="post-meta">
<div class="fleft">Posted in: <?php the_category(', ') ?> | <time datetime="<?php the_time('Y-m-d\TH:i'); ?>"><?php the_time('F j, Y'); ?> at <?php the_time() ?></time> , by <?php the_author_posts_link() ?></div>
<div class="fright"><?php comments_popup_link('No comments', 'One comment', '% comments', 'comments-link', 'Comments are closed'); ?></div>
</div><!--.post-meta-->
</header>
<?php echo '<div class="featured-thumbnail">'; the_post_thumbnail(); echo '</div>'; ?>
<div class="post-content">
<div class="excerpt"><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,50);?>Read more</div>
</div>
</article>
<?php endwhile; ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<nav class="oldernewer">
<div class="older">
<?php next_posts_link('« Older Entries') ?>
</div><!--.older-->
<div class="newer">
<?php previous_posts_link('Newer Entries »') ?>
</div><!--.newer-->
</nav><!--.oldernewer-->
<?php endif; ?>
<?php $wp_query = null; $wp_query = $temp;?>
</div><!--#content-->
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
Unfortunately this theme doesn't have any documentation so I'm forced to find my own solution.
Actually I already faced this situation in WordPress.
Its not fault of your code. Might be WordPress Bug.
Try to change your page name once.
Like
<?php
/**
* Template Name: Blog_new
*/
?>
And login again and check if it is showing new custom page option or not.
I'm working with a theme I paid for a long time ago, customized a bunch graphically and with the CSS and am pulling pieces of it into separate directory via iFrame Fancybox.
BUT, I'm trying to reformat the blog template - as currently it renders and populates when updated as:
Title
etc etc
A few lines of Content here/ then cuts of mid sentence.
Read More , etc // And these links just refresh the page?
So, I'm a bit novice with PHP & am wondering how I'd edit the below 'Blog Template' code to allow full posts text to display, not excerpts that are cut off in the middle:
<?php
/*
Template Name: Blog Template
*/
get_header();
?>
<div id="content">
<?php
//get exclusions for categories
$exclude = get_option($shortname.'_exclude_categories');
$exclude = str_replace(',,','|-',$exclude);
$exclude = str_replace(',','-',$exclude);
$exclude = substr($exclude, 0, -1);
$exclude = str_replace('|',',',$exclude);
query_posts('posts_per_page=&paged='.$paged.'&cat='.$exclude);
if(have_posts()) : while(have_posts()) : the_post();
?>
<div class="entry" id="post-<?php the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<p class="meta">Added by <?php the_author_posts_link() ?> on <?php the_time('F jS, Y') ?>, filed under <?php the_category(', ') ?></p>
<div class="entry-content">
<p><?php the_post_thumbnail('wide'); ?></p>
<?php the_excerpt('Read the rest of this entry »'); ?>
<p><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> ~ Add your thoughts | Continue Reading</p>
</div><!-- e: entry content -->
</div><!-- e: entry -->
<?php
endwhile;
//endif;
?>
<div class="paginate">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>
</div><!-- e: content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Replace the_excerpt() with the_content(), that's it.