How to show content without featured image - wordpress

I have add a new post from admin panel of wordpress and the post is showing on home page.when I have added the featured image of the post then post is coming with full content means post title, post description, read more and featured image.
but when I have add post without featured image then the it is showing me only description of the post without title,read more button.
So please help me how can i show post content,excerpt and date etc of post without featured image.

Used as a replacement for the_content() to force excerpts to show within The Loop.
<?php the_excerpt(); ?>
//inside brackets you can give limit for exerpt
for date you can use within loop
<?php the_time('F jS, Y') ?>

Related

How to Remove wordpress Featured Image on Posts

I am using the Hueman wordpress theme in my home. I want to show the featured image on the post but I don't want to that image in a single post.
Can anyone help with this? Here is the link
I think you want to customize single post detail page.
So, go to single.php.
Usally this file is located in your theme path that is as below.
www.domain.com/wp-content/themes/your-theme-name/
Go to above path and open single.php. In that remove below code get_template_part( 'content', get_post_format() ); and replace it with
the_title(); //For Post Title
the_content(); //For Content of the post
If you want to add image use the_post_thumbnail( 'single-post-thumbnail');

WordPress: display full post AND excerpts on one page

Is there a way my category archive display both full posts and excerpts?
What I want is the first two or three latest posts display as full content posts, and all the others as excerpts with just title and a read more button. These are displayed on one page. I am currently using a category archive, on the twentyfifteen theme.
I know I can set a page to either display full or just excerpts, but not a combination. Is this possible?
Thanks!
You can get these in your wordpress loop on page or post.
<?php
$content = get_content($post->ID); //full content of post
$excerpt = substr($content,0,150); //you can limit charaacter like 150
?>

How to show page title in blog post of wordpress site

I want to show the page title in single post page of wordpress theme. I tried to use <?php echo get_the_title() ?> but it return the post title, not the page title.
basically I want to show MY page title, in this case "Blog" below my header area in single.php file. how do I make it?
In order to get page title you need to use WordPress API function use the code below
<?php
$post_7 = get_post($id);
$title = $post_7->post_title;
?>
In wordpress both posts and pages have ids. So same function will work to get title of either post or page.
You have to pass this parameter to get the title of the page.
For reference see this link
http://codex.wordpress.org/Function_Reference/get_post

Add a "details" view to NextGEN Gallery?

I am working on a site with WordPress for a client who wants to showcase her products online, but does not want to sell them over the web. I have a simple photo gallery set up with the NextGEN Gallery plugin. Upon clicking the thumbnails in the gallery view, instead of simply showing them in a lightbox or their own page, I would like to add a "details" page for each photo - kind of like the individual product pages on a shopping site, but without any of the shopping functionality. Would it be possible to do this using NextGEN gallery or another plugin, or do I have to do it from scratch (and how would I do that)?
Because NextGen doesn't actually create a WordPress 'Page' to link the single image to, you may be better off using the built-in WordPress Galleries (You may of seen the [gallery] shortcode). When you upload an image to a page or post, WordPress stores that image as a post in the wp_posts table, alongside all your other posts and pages.. with a post_type of 'attachment', and adds it to a 'Gallery' for the post or page. You can manage the current gallery for any page or post by clicking the 'Add Media' icon above the text editor. While the [gallery] shortcode is quite limited, you can use code in your theme to display the gallery and images anyway you want.
If it was me, I would make a 'Products' page and individual 'Product' pages as child pages of 'Products' (or if you want more flexibility, use a custom post type for the products) and then upload all the product photos into the 'Product' page galleries (creating a gallery per product) - and setting the primary image as the 'Featured Image' for each product page. Then in your 'Products' page template (page-products.php) I would make a loop to display all the individual Product page's featured images.. something like..
<?php
//Add this to your 'Products' page temaplte, page-products.php
$products = new WP_Query(array(
'post_parent' => $post->ID,
'posts_per_page' => -1
));
while ($products->have_posts()) : $products->the_post() ; ?>
<a href="<?php the_permalink() ?>" title="<?php the_title() ?>">
<?php the_post_thumbnail() ?>
</a>
<?php endwhile;
?>
That will create a list of the Product featured images, and you can use CSS to adjust the display - and each featured image will link to the individual product page.
Then in your individual Product pages (you can use a page template to target all of them), you can display the individual product gallery (like detail shots of the product) using get_children() or use the_post_thumbnail() again to display a larger close-up version of the primary photo. And of course, then you can use the post content of your individual product page to display the info text for each photo, like so:
<?php
/* Template Name: Individual Product */
while (have_posts()) : the_post();
the_post_thumbnail();
the_content();
endwhile;
?>
To take it another step further, you could add all sorts of other data about the individual product with custom meta boxes, and display them on the side of the page or something.. like 'Product Size', 'Color', 'Foo', 'Bar'.. anything really. Hope that helps!

Associating an image with a post in WordPress

What's the best way to associate an image with a post in WordPress?
What I mean by that is when each post has a 'header' image which is not in the body of the post. You'd most likely use it to show a small image next to each post when they're listed somewhere.
I know you can use custom fields with posts, but are there any better ways of doing it?
Thanks in advance.
If you go the custom field route - in your template code you can save the value of the custom field to a variable and then echo it out to your image.
<?php $post_image = get_post_meta($post->ID, post_image, true); ?>
<?php if( $post_image != "" && isset($post_image) ) : ?>
<p><img src="<?php echo $post_image; ?>" alt="<?php echo $post_image; ?>" /></p>
<?php endif; ?>
<?php the_content('read more...'); ?>
The function the_content() may or may not be what you will end up using - for more control, you can try setting a new WP_Query() and then revamping the loop.
Not really any better way than custom fields, although you could always write out a unique class name containing the post ID on the container div and add the images via CSS each time you add a post. You'd end with a potentially huge CSS file though so I'd go for custom fields myself.
If you want a different image per post then use Customs Fields as suggested before - the only problem with that will be that Custom Fields are text fields and so you will have to upload your image and then paste the filename into your Custom Field. You could use the normal Add Image facility in the main post entry form but that will break up your workflow a bit as you will have to: upload the image in main post form, copy image url from HTML of form, remove image from form, paste URL into a custom field.
A bit of a pain!
If you want to use an image per category. Say, for example, you have a thumbnail for news items and a thumbnail for tutorials and so on. You could edit your WP theme template, check the category inside The Loop and show the relevant image from there.
The first option is a bit of a pain and the second requires some PHP coding.
A good way of associating an image with a post is to call the first image attached to that post in your template file.
I've elaborated a bit in this thread:
How would you recommend adding an image as a custom field in WordPress?

Resources