Building wordpress one-page portfolio with additional image gallery - wordpress

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?

Related

configure parent/child relationship between 2 Custom Post Type only in child

I would like to create a relationship between 2 Custom Post Type avoiding that the user has to go to both to create the link.
In absolute terms, I would like the user to go to only one Custom Post Type (writing) which remains fairly basic: A title field, a text field, an image field, a link field for documents or url, and finally a selector field to select its parent (created with ACF).
In the hierarchy of the site, these posts created are at the end of the race, therefore, are only post children. They will display with "single.php".
The site obviously contains different menus which also have different sub-menus, a front-page.php for the home page, for the main menus we have the archive pages and for the sub-menus of the single pages.
The other Custom Post Types are the site menus which each contain their respective submenus. The user doesn't have to go here, hence I would like to create a parent/child relationship only by going into the child Custom Post Type.
For example, in my home page (front-page.php), I have a "Company" part if I click on it, I arrive on "archive.creb.php" where there is "Office", Secretariat" and "Management", if I click on "Office" I arrive on "single.creb.php", in this part, there is "the team" and "the calendar", if I click on "the team", I arrive at "single.php".
The team page (just like the "calendar" page) is an article written by the user.
So I'm looking for a way so that, when the user creates an article, he can choose where it will be (with the ACF selector field), and therefore choose its parent AND in addition, that the link of the article appears in this parent.
I know how to do this kind of operation by configuring a relational field in the 2 Custom Post Types concerned with ACF, but not with just one.
I did some research, especially on the ACF doc and I found this:
https://www.advancedcustomfields.com/resources/relationship/
https://www.advancedcustomfields.com/resources/querying-relationship-fields/
So I tried to adapt the ACF example with my code, but it's not easy because it's not quite the same... By schematizing the ACF example to mine, it gives this:
In both cases there is indeed a selection field creation, except that in the ACF example its selector chooses the child and I choose the parent. So I tried to reverse, using the code from single.location.php in my single.creb.php.... But it doesn't work.. my single.creb.php page shows a link loop to himself
So... I hope I was clear in my question! Hoping for an answer
Here are some codes :
functions.php
function custom_post_type(){
$arg = [
'public'=> true,
'label'=> 'CREB',
'show_in_rest' => true,
'supports'=>array('title', 'thumbnail', 'excerpt'),
'has_archive'=>true,
'menu_icon'=> 'dashicons-groups'
];
register_post_type('creb', $arg);
$arg = [
'public'=> true,
'label'=> 'redaction',
'show_in_rest' => true,
'supports'=>array('title', 'thumbnail', 'excerpt'),
'has_archive'=>true,
'menu_icon'=> 'dashicons-book-alt'
];
register_post_type('redaction', $arg);
}
add_action('init', 'custom_post_type');
single-creb.php
<?php get_header(); ?>
<!-- single creb -->
<main id="" class="">
<div class="">
<h1 class="">single CREB</h1>
<?php
if(have_posts()){
while(have_posts()){
the_post();
the_title();
$redac = get_field('textesousmenu');
if($redac){
echo $redac;
};
};
};
?>
</div>
</main>
<?php get_footer(); ?>
single.php
<?php get_header(); ?>
<!-- single creb -->
<main id="" class="">
<div class="">
<h1 class="">single</h1>
<?php
if(have_posts()){
while(have_posts()){
the_post();
the_title();
$redac = get_field('texte');
if($redac){
echo $redac;
};
$img = get_field('img');
if($img){
echo wp_get_attachment_image($img, 'modale');
}
if (have_rows('liendocurl')){?>
<ul class="">
<?php while (have_rows('liendocurl')){
the_row();
$nom = get_sub_field('nomlien');
$docurl = get_sub_field('urllien');?>
<li>
<a href="<?php echo $docurl; ?>" target="_blank">
<?php echo $nom ?>
</a>
</li>
<?php } ?>
</ul>
<?php }
$lien = get_field('relation');
if($lien){?>
<ul>
<?php
$name = get_the_title($lien->ID);
$link = get_permalink($lien->ID);
?>
<li>
<a href="<?php echo $link;?>">
<?php echo $name; ?>
</a>
</li>
</ul><?php
}
};
};
?>
</div>
</main>
<?php get_footer(); ?>
thank you in advance

Changing Default Title on WooCommerce Single Products Pages

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>

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.

Customize the display of a widget in a sidebar [wordpress]

Currently during the sidebar registration we can mention "before_widget" and "after_widget". But this limit the extent we can wrap the widgets.
Is there a way I can display the widgets in any manner I want to, within a sidebar
e.g
<?php foreach($widgets as $widget): ?>
<div>
<h1>heading</h1>
<p>details</p>
<?=widget->show()?>
</div>
<?php endforeach; ?>
Thanks.

Resources