Changing Default Title on WooCommerce Single Products Pages - wordpress

I suppose this is something simple, but couldn't find a solution anywhere.
Currently, my website shows <h1>"Products"</h1> title on shop archive page, but on single product pages as well. Is it possible to change default title on single product pages to product name?
Here is my website. As you can see, above breadcrumbs, there is a default shop title. And there I want to display, product name instead.
<section class="<?php echo esc_attr($class_name) ?>" <?php echo wp_kses_post($bg_style); ?>>
<div class="page-title-inner">
<div class="container"><h1><?php echo esc_html($page_title); ?></h1> <?php great_store_the_breadcrumb(); ?>
</div>
</div>
</section>

Related

Building wordpress one-page portfolio with additional image gallery

I'm creating a custom theme with bootstrap that will be used by a photographer and I'm trying to integrate it with wordpress. My main page is in the one-page style and has following sections:
cover image with page title and description
about me section
portfolio with 6 exemplary photos and link to full gallery
contact form
"About me" content can be edited in the admin panel (I created a separate "about me" page and linked up its ID with the section), portfolio photos are the featured images of the latest posts.
Navbar consists of sections titles as well as link to the gallery.
And here are my questions and problems that I need to solve:
1) How can I add a functionality to edit the cover image from the admin panel?
2) How can I display only posts from one category?
I thought about categorizing the posts with "gallery" and "portfolio" when all of the first ones would be posted in gallery, but also some of them would be featured on the home page in portfolio section.
Is it a good way to do that? How can it be achieved in code? Here is how the portfolio code looks like at the moment:
<div class="row">
<?php
$i = 1;
query_posts('showposts=6');
query_posts("catname=portfolio");
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<div class="col-sm-4 portfolio-item">
<a href="#portfolioModal<?php echo $i; ?>" class="portfolio-link" data-toggle="modal">
<div class="caption">
<div class="caption-content">
<i class="fa fa-search-plus fa-3x"></i>
</div>
</div>
<?php
the_post_thumbnail( 'full', array('class' => 'img-responsive') );
?>
</a>
</div>
<?php $i++; ?>
<?php endwhile; endif; ?>
It publishes all of the featured images of the posts in the portfolio section. What shall I add there to display only posts categorized as 'portfolio'?
3) What is the best way to create a separate gallery in my case?
Should I create the "index.php" file with all of the code in "../gallery" folder and link it up in navbar? What should be the link destination in navbar that would lead to the gallery?

how to get the posts of a particular category from slug name when passing through url in wordpress?

I have a link with me. This is the link:
http://localhost/rajab/product-category/pvc-hose/
I have made a a category "PVC Hose" having slug name "pvc-hose" and displayed on a page. when i am clicking this category, it goes to a link as shown above.i wanted to display all the posts in this category on linked page. Can anyone say how to display it there.
Simply create a taxonomy.php file in your root folder with the following code
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
// Your markup and template tags like
the_title();
echo '</br>';
}
}
<li class="cbp-item houses cbp-l-grid-masonry-height1">
<a class="cbp-caption cbp-lightbox" data-title="PVC Air Hose" href="<?php bloginfo('template_url'); ?>/images/buiding/pvc/img1.jpg">
<div class="cbp-caption-defaultWrap">
<img src="<?php bloginfo('template_url'); ?>/images/buiding/pvc/img1.jpg" alt="">
</div>
</a>
<h4><?php $data->post_title; ?></h4>
</li>
i wanted to repeat this code in the taxonomy file..I wanted to display not only the title and content but also featured image.

Pluginf for Different header image on every pages in wordpress

I need wordpress plugin for this kind of header image http://www.slb.com/services/drilling.aspx like in this web site. And this image will not be slider but it's static image on perticular page and category and also different image for all categories and pages.
Easiest & best way is create a custom field named banner & in your header.php place below code.
<div class="banner">
<?php if(get_post_meta($post->ID, 'banner', true)) : ?>
<img src="<?php echo get_post_meta($post->ID, 'banner', true); ?>" />
<?php endif; ?>
<div>
But as you want plugin to do this, have a look at plugin named Dynamic Header.

Reduce number of posts depending on post content

In a custom post archive; Is it possible to reduce the the number of posts shown, depending on the contents of the showing posts?
I have a custom post type for products. In the product archive there are 20 products showing on each page, 4 rows, 5 cols.
In some cases where the product image is super wide I'd like that product to be shown with double width.
When showing a super wide product, I'd like to reduce the number of posts to 19 (18 if there are two super wide products). Keeping the bottom line straight.
This is the loop for my custom post archive.
I got your point with numcols. And as you say, I should probably modify the query, making sure that page 2 and 3 (and on) shows the right posts.
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>" class="produkt_item normal various" data-fancybox-type="iframe">
<?php if ( has_post_thumbnail() ) { ?>
<div class="utvaldbild">
<?php the_post_thumbnail('produktbild'); ?>
</div>
<?php } ?>
<h2><?php the_title();?></h2>
<p><?php the_field('produktnotis'); ?></p>
<?php if (get_field('nedladdning')) { ?><div class="nedladdning"></div><?php } ?>
</a>
<?php endwhile; ?>
you could add a custom field to your post custom posttype called numcols or something like that. normal products would be 1 and super images 2 etc.
then just keep a count of them in your php code and cut off when appropriate.
you could probably modify the query in the lookup page to do this but I'd have to see some code to be of any help. ideally your custom product archive page and the definition of your custom post type.

How to retrieve all custom posts from all the categories in portfolio

I have created custom post type portfolio in wordpress. I have created categories like web-design, logo design, e-commerce, photography... etc. I have retrieved all these category as the navigation menu in portfolio template file (assigned to the portfolio page). Now I want there should be a link(view all) in the navigation menu which will retrieve all the posts from all the categories in portfolio. Basically I want a way for making default category which will retrieve all the posts. Can anybody please help me!!!
So, basically, you want to create a Custom Post Type Archive page.
A way to achieve this, as explained at WPBeginner.com, is like the following:
Create a custom page template (the PHP file could have any name you want) and Add the Template Name comment at the beginning of the file:
<?php /* Template Name: Custom Post Type Archive */ ?>
Create a custom loop:
<?php
/* Template Name: Custom Post Type Archive */
get_header();
?>
<?php
global $query_string;
query_posts($query_string . "post_type={YOUR-CUSTOM-POST-TYPE}&post_status=publish&posts_per_page=10");
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<?php
endwhile;
endif;
?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('Previous entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next entries') ?></div>
</div>
<?php wp_reset_query(); ?>
<?php get_sidebar(); ?>
<?php get_footer();?>
Create a new page and select the template you just created in the Page Attributes box
You should be able to use the archive page template to list them all then. Try going to http://yourdomain.com/portfolio and see if that brings it up. You will need to have enabled archives for the post type when you created it though. Look for 'has_archive' => true, if you created the post type manually by dropping in the code in your functions.php file. If you see that, but its set to "false", you'll need to change it to true.
You could also create a custom archive template for this post type if you wanted to. If you create a new file in your theme directory called archive-portfolio.php and then put a custom loop in there the post type will automatically target that template file when accessing the post type archive.
Then to link from your nav menu to this archive, just create a custom menu item in your menu editor with the url http://yourdomain.com/portfolio. You won't need to create any sort of "default" category if you take advantage of the post type archives.
Let me know if you have any other questions.

Resources