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!
Related
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') ?>
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');
I have a page on my Wordpress website called Blog, this is set to a static page and is the Blog page so it has a list of blog posts. On the blog page I have a featured image set. I want to use this featured image as a background image on the Blog page.
home.php (template for blog page):
At the top of home.php before the Loop that pulls the list of blog posts I have:
<?php
$page_id = get_queried_object_id();
if ( has_post_thumbnail( $page_id ) ) :
$image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $page_id ), 'optional-size' );
$image = $image_array[0];
else :
$image = get_template_directory_uri() . '/images/default-background.jpg';
endif;
echo $image;
?>
<div class="feature" style="background-image: url('<?php echo $image; ?>')"></div>
This works and it sets the featured image. However it seems to have set the featured image on every single page on the website to the featured image from the Blog page. Even after I changed the featured image on the About Us page it still pulls the URL for the Blog page's featured image and sets that as the featured image on the About Us page.
I have the website here: http://www.cqwebdesign.co.uk/Action-Harpenden-Physiotherapy/
As you can see by these screenshots I have set different featured images on the Blog and About page:
http://i.imgur.com/DnU8V9F.jpg
http://i.imgur.com/qshulWT.jpg
Anyone know how I can fix this?
As the home.php template affects only your Blog Page, it would be interesting how your page.php template code looks like (Notice: page.php is the default template for pages like your 'About' Page) and why the featured image isn't shown correctly on this page(s).
Try to debug or echo your id values for the Blog Page and the About Page and verify if the corresponding page id is the same as the one referred by get_queried_object_id();.
I think you're having a page.php template but just in case, if you don't have one please notice Wordpress' Template Hierarchy
Wordpress Codex:
When the static front page feature is configured properly, WordPress will not use a Custom Page Template to display the blog posts index, even if a Custom Page Template is assigned to the page designated as the "Posts page". WordPress will only use either home.php or index.php.
In one theme (FloZo) I've seen a nice functionality and I would like to learn how to make something similar. It's about a portfolio page, take a look at the demo "Our Work section".
You create a page and give it a template (Work archive) via Pages menu - more or less understood
You don't add any pictures there!
In your Dashboard you have a nice "work" section, where you can choose "make a new work item" - you add pictures with titles and descriptions there. - This is the big trick!
Now: my newbie idea on how it works:
The template is just the "body" of the page with the title
The dashboard "work" section must be doing something like this:
When you post a work item, it pastes/appends the whole item code into your page (like an item template code) with your specific image and text. It also creates an item-specific page (it's where you end up after clicking on an item).
My question is: is there any slightest possibility to add such a functionality to a Wordpress theme?
Here is how I see it:
The page template, 'Work Archive' has the loop that is displaying posts of 'Work' post type.
So to achieve this first you have to add the custom post type of your liking, and then in the page template add a custom loop to display these:
<?php
$args = array(
'post_type' => 'your_post_type',
'posts_per_page' => -1 //or whatever you choose
);
$work_query = new WP_Query($args);
if ($work_query->have_posts()) : while ($work_query->have_posts()) : $work_query -> the_post(); ?>
<!-- loop content goes here -->
<?php
endwhile;
endif;
wp_reset_postdata(); // always reset post data after custom loops
?>
If you need more info pleae don't hesitate to ask.
Happy coding!
I'm using Wordpress page templates to pull posts with certain categories into their own page. My problem is that they are also showing on the home page. I know how to hide categories from the home page entirely, but I'd like a toggle so that if it's checked, it will post to home page and sub-page and if it's not checked, it will display only on the sub-page. Does that make sense?
This code is on the "Awards" template and pulls in posts containing the category slug "awards".
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'category_name' => 'awards', // Change these category SLUGS to suit your use.
'paged' => $paged
);
query_posts($args);?>
The "awards" category is then blocked from the home page using a query_posts tag:
<?php if ( is_home() ){
query_posts( 'cat=-5' ); //-5 is the category id for 'awards'
}?>
I tried to get around this by also tagging the post with a category that isn't blocked from the home page, but it apparently doesn't care that it's tagged with something else.
So my conundrum is that I would like a simple option (hah) that allows me to pick and choose if it belongs on the home page or not, while still having them all show on this other page.
Well.. in the middle of writing this, I was inspired and sure enough I found the simple solution. 'Uncategorized' is the default category and has the id of 1. On the index page, I simply added the 'query_posts( 'cat=1' );' underneath the bit of code that blocks the other categories. This way, I can tag it for the category I want on one of the sub pages, but also for ones that I want to show on the homepage. Here is the code as it is on my index.php:
<?php if ( is_home() ){
query_posts( 'cat=-5' );
query_posts( 'cat=1' );
}?>
So if I want it on the home page AND the subpage, I'll categorize it as 'awards' AND 'Uncategorized' (or whatever you choose to be the homepage category). If I want it only on the subpage, I just choose that category. This works because the 'query_posts( 'cat=1' );' is written below the 'query_posts( 'cat=-5' );' part, so it's happening after the block which tells the server to display it after all.
Is it an option to use a Wordpress Plugin?
If so, you can use WP Hide Post, which enables a feature to hide certain posts to show on the frontpage.
Here is the link to the resource:
http://wordpress.org/plugins/wp-hide-post/