How to display author name near the date on my website homepage and single post page? . Is there is css code for that. Iam using hemingway theme. And my website is www.avjtrickz.com . please help me, Thanks for advance.
You have to use:
<?php $author = get_the_author(); ?>
or:
<?php the_author(); ?>
Here you can find more information: https://codex.wordpress.org/Function_Reference/get_the_author
And here: https://codex.wordpress.org/Function_Reference/the_author
And here: Show Author name in single.php (Wordpress)
This needs to be done using the WordPress codex for author. This reference needs to be used in the Loop. There is no CSS for this.
https://codex.wordpress.org/Function_Reference/the_author
<?php $name = get_the_author_meta( 'display_name' ); ?>
reference : https://developer.wordpress.org/reference/functions/get_the_author_meta/
Related
I want to show home page title in breadcrumb. I have tried the get_the_title() function, but it requires page id as parameter. I believe it will break when I change the front page to other page.
Is there a function that is more change prone?
this is how I solved my problem
$home_title = get_the_title( get_option('page_on_front') );
that way, when I change home page with diferent page, the code won't break. It also works on multisite.
Please try this..
<?php echo bloginfo('title'); ?>
<?php echo bloginfo('title'); ?>
This will echo you title of your website given in settings.
Can help somebody. I spent several hours to find solution but without results
I tried to display the list of categories on homepage wordpress blog thru following code
<?php $category = Mage::registry('wordpress_category') ?>
<?php if ($category): ?>
<?php echo $category->getId() ?>: <?php echo $category->getName() ?>
<?php endif; ?>
But the method
Mage::registry('wordpress_category')
always return null.
I found that, i should probably be using the Fishpig_Wordpress_Block_Category_View. But i dont know where i should put it.
The following code will retrieve the current category when viewing a category page in your blog:
<?php Mage::registry('wordpress_category') ?>
This is not what you need. To view a list of categories, you could create a custom collection using the following:
<?php $categories = Mage::getResourceModel('wordpress/post_category_collection') ?>
A better way would be to use the category widget block:
<block type="wordpress/sidebar_widget_categories" name="wp.categories" template="wordpress/sidebar/widget/categories.phtml" />
You can create this in PHP using the following code:
<?php echo Mage::getSingleton('core/layout')
->createBlock('wordpress/sidebar_widget_categories')
->setTemplate('wordpress/sidebar/widget/categories.phtml')
->toHtml() ?>
The above code uses the default template, however, feel free to use your own custom template.
I am using wordpress 3.6 and advanced custom field plugin 4.2.1.
advanced custom field settings - https://dl.dropboxusercontent.com/u/15109395/q/acf-media.png
my post - https://dl.dropboxusercontent.com/u/15109395/q/page-content.png
my single page code
<section id="contentLeft" class="single">
<?php if ( have_posts() ) { the_post(); the_content(); }?>
</section>
Result - https://dl.dropboxusercontent.com/u/15109395/q/page-front.png
but , i don't want that attachment image on content area. my local installation have no problem. not showing attachments. but my live website showing attachment uploaded to that post.
how can i solve this issue? please help me. Thanks.
My problem solved with this solution. Thanks.
http://wordpress.org/support/topic/thumbnails-magically-appearing-on-all-pages
if you want remove images from all posts and pages, simple copy the following code into your theme functions.php
<?php
function remove_images( $content ) {
$postOutput = preg_replace('/<img[^>]+./','', $content);
return $postOutput;
}
add_filter( 'the_content', 'remove_images', 100 );
?>
it will remove the images wherever the_content() have images
else you need to include this function in specific page , put the following code
<?php remove_filter( 'the_content', 'remove_images' ); ?>
So I made a "Custom Post Type" for Wordpress and also made a single-*.php (single-yourcustomtype.php) for content-display.
Code from single-*.php:
<?php $author = get_the_author(); echo $author; ?>
It works in the content.php, but not in the single-*.php...
Any idea why is it not working or how can I display out author's name?
Thanks in advance.
Have you tried adding
global $post;
I'm creating a custom post type for creating gallery posts. One of the things I took out was the 'editor' section since I have my own uploader. Since the HTML editor is gone (can't use shortcodes now), is there a wp function which is the equivalent of the [gallery] shortcode?
As per the Codex recommendation for outputting the [gallery] shortcode content directly in a template file, I would use do_shortcode():
<?php do_shortcode( '[gallery]' ); ?>
You can even pass accepted parameters:
<?php do_shortcode( '[gallery columns="4" size="medium"]' ); ?>
Got it. Here's the code for anyone else who wants to do the same thing. Throw this baby in your theme template file and try it out.
$images = get_children(array('post_parent'=>$post->ID, 'post_type'=>'attachment', 'post_mime_type' => 'image'));
foreach($images as $image){
echo wp_get_attachment_link($image->ID);
}
You can use the wordpress function make for this purpose
gallery_shortcode(array('orderby'=>ID));
by sure to call this after you setup the post