Wordpress Author details not displaying on landing page - php

In Wordpress the default behavior is that all posts are displayed on the landing of the domain(myblogsite.com) but the post's displayed don't show the author's name or gravatar. This is only shown if the user selects an individual post(myblogsite.com/date/title). Is there a plugin or fix(or hack) to display the author name and gravatar for posts that are displayed on the landing page?
I've looked at similar questions on Wordpress' forum and the solutions I've tried did not work.
As an example:
Add this after or before <?php the_content(''); ?>
<?php if ($lw_post_author == "true" && is_attachment() != TRUE) : ?>
<div class="about_author">
<div class="alignleft"><?php echo get_avatar( get_the_author_id(), '28' ); ?></div>
<div class="alignleft"><h4><?php _e('Author','lightword'); ?>: <?php the_author(); ?></h4>
<?php the_author_description(); if(!get_the_author_description()) _e('No description. Please complete your profile.','lightword'); ?></div><div class="clear"></div> </div>
<?php endif; ?>
I am using Wordpress 4.4.2

Related

Navigating through WordPress custom posts

I want to redesign my website using WordPress and Bootstrap. I did most of the work, however, I have trouble navigating through my pages.
Before I tell you anything, just want you to know that my "tutorials" is "tutorijali" and my "tutorial" is "tutorijal". So just added that "j" there (because I'm not from England or English-speaking country).
OK, so, I made a custom post type "tutorijal". But, I noticed that when the custom post type's name is "tutorijal", I get the URL like this :
domain-name/tutorijal/
...
Since "tutorijal" is singular and "tutorijali" is plural, I changed the custom post type's name to "tutorijali" (so that my URL goes as I want it to go).
Then I made page-tutorijali.php and applied that theme (which I named "Tutorijali theme") to my XHTML and CSS page. But, what happens is that I have a conflict.
In WordPress, I have a Wordpress page named "Tutorijali" and my custom post type's name is also "tutorijali".
You can see my navigation structure here and notice that I have a WordPress page which is named the same as my custom post type, "Tutorijali" : http://imgur.com/2zgH5dD
If I go to
domain-name/tutorijali/xhtml-and-css
I get my default post template and not the "Tutorijali theme" I applied. However, that "Tutorijali theme" is applied on Tutorijali WordPress page, without me ever setting it to be applied.
So, if you go to
domain-name.com/tutorijali
you can see the ordered list with all of the tutorials, however, if you go to a specific sub-item of the WordPress page "Tutorijali", you get the default post template, even if you specifically change that WordPress page (from the Admin panel) to "Tutorijali template".
Maybe my WordPress page and my custom post type can't share same name, I'm not sure.
Now, I when the user goes to
domain-name/tutorijali
I'd like him to have only the names of tutorial series, but if he goes on one specific serie, let's say XHTML and CSS, then the URL would be
domain-name/tutorijali/xhtml-and-css
and the user would get all of the XHTML and CSS tutorials in ordered list.
I have a parent custom post which is named "XHTML and CSS" (as my tutorial serie name) and it's child elements (also custom posts named "tutorijali") are specific tutorials from that serie.
I also have one other problem, and that is that my list is also displaying the parent post, so my list goes like this :
XHTML and CSS (since it's "order" value is set to 0)
Installing the program ("order" set to 1 and so on)
Tags
Basic elements of a website ...
So I'd like to get rid of that and obtain the structure I wanted (on Tutorijali - tutorial serie names, on specific tutorial serie - list of the tutorials).
Here's the code for my page-tutorijali.php :
<?php
/*
Template Name: Tutorijali Template
*/
?>
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="page-header">
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(); ?>
<?php endwhile; else :?>
<div class="page-header">
<h1>O ne!</h1>
</div>
<p>Na ovoj stranici nema sadržaja.</p>
<?php endif; ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
$args = array( 'post_type' => 'tutorijali', 'order' => 'asc', 'posts_per_page' => -1 );
$the_query = new WP_Query( $args );
echo "<ol>";
if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
echo "<li>";
echo "<a href='".get_permalink()."'>".get_the_title()."</a>";
echo "</li>";
endwhile; endif;
echo "</ol>";
?>
</div>
</div>
<?php get_footer(); ?>
I also have a question regarding my single-tutorijali.php. I have created it to display these custom post pages differently than "normal" posts. I link to the previous and to the next tutorial well, however, I don't know how I can link from a tutorial to the list.
So let's say the user is at the tutorial "Installing the program", URL would go :
domain-name/tutorijali/xhtml-and-css/installing-the-program
and if he clicks on the link to take him back to the list, he would go to :
domain-name/tutorijali/xhtml-and-css
but I have trouble doing that, so maybe you can tell me how I can do that.
Here's the code for my single-tutorijali.php :
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="page-header">
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(); ?>
<?php endwhile; else :?>
<div class="page-header">
<h1>O ne!</h1>
</div>
<p>Na ovoj stranici nema sadržaja.</p>
<?php endif; ?>
</div>
</div>
<div class="row">
<div class="col-md-12 yt-link">
<p> <a class="btn brn-large btn-primary" href="<?php the_field('link'); ?>"> Pogledajte tutorijal na Youtube -u </a> </p>
</div>
</div>
<div class="row">
<div class="col-xs-12 prev-next">
<?php previous_post_link('%link', '<span class="glyphicon glyphicon-circle-arrow-left"></span>'); ?>
/-- this is that link I was talking about, one that takes you back to the list of tutorials
<span class="glyphicon glyphicon-th-list"></span>
/--
<?php next_post_link('%link', '<span class="glyphicon glyphicon-circle-arrow-right"></span>'); ?>
</div>
</div>
<?php get_footer(); ?>
Thank you for reading!

php if in category not detected

I am using advanced custom fields with wordpress.
I am trying to make it that if a subfield has a category of 8 it displays its repeater fields. If not it doesn't show the other posts.
However this doesn't seem to work and display the content:
<?php while(has_sub_field('team_profile')): ?>
<?php $cat = 8;
if (in_category($cat)) {
?>
<li class="col-lg-3 teamProfile">
<h2><?php the_sub_field('profile_name'); ?></h2>
<p class="jobTitle"><?php the_sub_field('category'); ?></p>
</li>
<? } ?>
<?php endwhile; ?>

How Can i Remove all sidebars from specific wordpress pages?

hi everyone im trying to remove all of the sidebars from a specific video page im creating on a wordpress site ive found tutorials on google on how to do this if the sidebars are called to the page using the
<?php get_sidebar(); ?>
method however my theme uses following method to call sidebars to a page
<?php include(TEMPLATEPATH."/sidebar.php");?>
i cant find any good methods for removing the sidebars that calls them to a page the same way as my theme does. here is the code to my page.php file on my website any help understanding how to remove them would be greatly appreciated =)
<?php get_header(); ?>
<div id="breadcrumb"><?php breadcrumbs(); ?></div>
<?php include(TEMPLATEPATH."/sidebar.php");?>
<div id="kontenutama">
<div class="postingan">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark">
<?php the_title(); ?></a></h2><?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<br style="clear:both;">
</div>
</div>
<?php include(TEMPLATEPATH."/r_sidebar.php");?>
<br style="clear:both"><div style="clear:both">
</div>
<?php get_footer()?>
Why not create a new WordPress page template and remove the sidebar include on that page?
The theme is pretty dodgy, it shouldn't ever include files like that in template pages.

Editing Theme to apply Co-Authors Plus

I'm trying to implement the Co-Authors Plus Plugin. It says that you will need to change some PHP in the theme. It outlines the changes on this Link.
I believe I have found where I would need to change it in my theme. In a file called "post-author-info.php".
This is what it looks like:
<?php
/**
* Post Author Info
*
* #package WP Journal
* #subpackage Include
*/
?>
<div id="authorinfo" class="columns alpha omega marT30 marB20">
<?php echo get_avatar( get_the_author_meta('email'), '80' ); ?>
<h5 class="marB10"><?php _e('By', 'contempo'); ?>: <?php the_author(); ?></h5>
<p><?php the_author_meta('description'); ?></p>
<div class="clear"></div>
</div>
Just adding this line <?php if ( function_exists( 'coauthors' ) ) { coauthors(); } else { the_author(); } ?> seems to give me something that I want. Both "Admin" And "Andrew Gable" are displayed.
Here is the screen shot when changes are applied.
I'm unsure on how to get it to link correctly, and how to handle photos and multiple Bio's.
Thanks
You might wanna post this question at https://wordpress.stackexchange.com/
I had a similar issue and resolved it this way:
global $post;
$author_id=$post->post_author;
foreach( get_coauthors() as $coauthor ): ?>
<div class="entry-author co-author">
<?php echo get_avatar( $coauthor->user_email, '96' ); ?>
<h3 class="author vcard"><span class="fn"><?php echo $coauthor->display_name; ?></span></h3>
<p class="author-bio"><?php echo $coauthor->description; ?></p>
<div class="clear"></div>
</div><!-- .entry-author co-author -->
<?php endforeach;
Be sure to use that global $post;and the foreach-loop.
This function will display an author box containing author image/avatar, author name with link to its archive, and the author's bio. You might want to use your own theme's CSS classes though.

Showing Wordpress posts on two pages

I have three pages on my site. Let's call them home, page2, and page3.
My 'home' page is set as a static front page. My 'page2' is set up as the blog page.
What I want is the following:
I want page2 to display blog posts with a certain category (of which ID is known).
AND
I want page3 to display blog posts with a certain category (of which ID is known).
The PHP code to only show posts with a certain category (or actually in my case, show posts excluding two categories) is the following:
<?php query_posts($query_string . '&cat=-3,-8'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h3>
<?php the_excerpt('Read the rest of this entry »'); ?>
</div><!-- /.post-->
Now, in my page.php, I have the following code to display posts with one category:
<?php
// BEGIN IF PAGE is newspaper articles page
if ( is_page('newspaper') ) {
//BEGIN POST REGION
query_posts($query_string . '&cat=8'); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><?php the_title(); ?></h3>
<?php the_content('Read more »'); ?>
</div><!-- /.post-->
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php
} //end if is_page
?>
But it doesn't show the proper posts on the newspaper page (or page3 in this question). It does, however, work for the articles page (main index.php blog page).
EDIT: I've also tried the following (but it doesn't work). I put this in the index.php file:
<?php
if ( is_page('newspaper') || is_home() ) { // START if is home
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to
<?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h3>
<!--<p><?php the_time('F jS, Y') ?> <?php //the_author() ?></p>-->
<?php the_excerpt('Read the rest of this entry »'); ?>
</div><!-- /.post-->
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
<?php
} //end if is_home() or is_page()
?>
Again, this shows the posts on the main blog page, but doesn't show any posts on the newspaper page...
The question is therefore simple (I think). How do I show posts on another page OTHER than the main blog page?
Thanks!
Amit
Rather than exclude categories and exclude pages and change the standard Wordpress loop, use a new query, like this:
<?php $my_query = new WP_Query('category_name=mycategory&showposts=1'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a></h3>
<?php the_excerpt('Read the rest of this entry »'); ?>
<?php endwhile; ?>
This can be used inside the standard WP loop and be used mutiple times in a page/post or page template without conflicting. (Enable php execution to use it in the page/post editor). Function Reference/WP Query « WordPress Codex
This also works well to use page templates to create different pages with blog posts: Page Templates « WordPress Codex, but don't forget that WP also uses category pages, too, depending on your theme: Category Templates « WordPress Codex.
I think you have to make different templates for different page. Check this link http://codex.wordpress.org/Pages
I think this thread answers the question and does what you want.
http://wordpress.org/support/topic/show-only-x-category-posts-on-page?replies=9#post-1053767
Using the string 'newspaper' in is_page('newspaper') is a potential source of the problem. It might be misspelled easily.
Have you ever tried using the page id? Something like
is_page('999')

Categories