WordPress multiple-submenu - php

What's the best way to make multiply-page menu?
For example Category1 -> Article -> Full article text?
Not dropdown menu.
There's site example: http://fl.jetcode.lv/service.html
There are on page "Услуги" (Services), list with point's (Обслуживание windows, Подключение интернета, Сборка компьютеров, Чистка вирусов, ...)
When i click one of them (for example 'Обслуживание windows'('Maintenance windows')), i need to get page with points of that category like Установка Windows XP /Vista /7 /8 / W.S 2003,2008 (Installing Windows), Установка Linux (Installing Linux). And each Category have their own list of that text. So what's the best way to make that?
By steps:
1. I'm here: http://fl.jetcode.lv/index.html
2. I click on 'Обслуживание windows', and go to that page http://fl.jetcode.lv/service.html
3. Now i see a list with services on that category
4. Click on 'Полное описание', under 'Установка Windows XP /Vista /7 /8 / W.S 2003,2008'
5. And get to that page http://fl.jetcode.lv/service_inside.html
So how i can structure that's menu with WordPress ?
I've created a Posts with first categories (Category1), then i added it to Appearance->Menus, and get that list on page. Now i can manage their content in post, but it will be hard for end-user. So i trying to make list with second-category in post, and stucked. So can somebody please advice how it correctly/better to do ?
Thanks!

To put this simply,
You won't be needed to change anything to header but in category.php.
Instead of including the <section id="menu"> in the header put it on categories.php then to the usual get post contents and you are done.
The logic isn't in the menu but the flow of how you call each file/element.
This is the sample structure in category.php
<h1 class="post-title"><?php single_cat_title(); ?></h1>
<!-- Display all posts under specific Category -->
<?php while(have_posts()): the_post(); ?>
<hr />
<div id="category-post">
<!-- Display the Post Title -->
<h1><?php the_title(); ?></h1>
<!-- Display the Date & Time of Post -->
<p class="post-date">Posted on <span><?php the_time('F j, Y'); ?></span></p>
<!-- Checks if the post has Featured Image, else will load
the default thumbnail called post-thumb.jpg.
Delete ELSE CLAUSE to remove default thumbnail feature.
-->
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( add_image_size( 'post-thumbnail'), array( 'class' => "post-thumb" ) );
}
else {
echo '<img class="post-thumb wp-post-image" src="';
echo bloginfo( 'stylesheet_directory' );
echo '/_/img/post-thumb.jpg" />';
}
?>
<!-- Display the excerpt if specified IF NOT, will display the
first 20 words in the actual content.
See functions.php for the excerpt lenght setting.
-->
<div class="category-content">
<?php the_excerpt();?>
</div>
<!-- Displays a link to the actual post -->
<a class= "category-read" href="<?php echo get_permalink() ?>">Read</a>
</div>
<?php endwhile; ?>
<!-- Displays the link for NEXT and PREVIOUS entries.
By default, only 10 posts per page can be loaded.
See [Settings > Reading] in Wordpress Panel to configure
-->
<div id='paging'>
<?php next_posts_link('« Older Entries ') ?>
|
<?php previous_posts_link(' Newer Entries »') ?>
</div>

Related

Show images from TEXT section on PAGE wordpress

I am trying to show all images on a Page in wordpress. My wordpress page is set up like you see in the image below.
What I want to do is show each of these images on a custom page I have made, called Portrait Album. See code below. I guess it is the opposite of this that i want to implement.
I am not sure how I can show each image in the Text section. Does anyone out there know how to do this? should be obvious but I cannot find an answer anywhere.
I know get_content() will show the content, but how can I specifically show the images, so I can show these in a loop enabling me to make a grid using css and create a photo gallery.
currently this is the code I have:
<?php /* Template Name: Portrait Album */ ?>
<?php get_header(); ?>
<div class="portrait-page" style="background-color: black;">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_content(); ?>
echo "<img src='".wp_get_attachment_url( $the_post->ID )."' />";
<?php endwhile; endif; ?>
</div>
</div>
</div>
What I want to do is something like this, where col-1-3 is one-third of the width of the page
<div class="row">
<div class="col-1-3">
echo "<img src='"RELEVANT PHP CODE HERE"' />"
</div>
</div>

How to show only the date, the title and a litle "summary" of my WordPress post in my custom theme?

I am pretty new in WordPress theme development and I have the following doubt about how show posts into a page.
I have this page belonging to an old custom legacy blog that I am build again using WordPress: http://www.asper-eritrea.com/comunicati.asp
As you can see in this page are presented some posts using the following structure: date followed by the post title followed by a short summary
What I want to do in WordPress is something like it.
So I have create this page that show the posts lists: http://lnx.asper-eritrea.com/category/legacyposts/
As you can see in this page are shown the posts (the formattation is horrible because I imported the post from the old website but I will work on it in a second time).
The main problem is that if the post is very long it is shows all of its contents.
This is the code of this page (category.php) is:
<?php get_header(); ?>
<!-- Contenuti (griglia) -->
<div class="container">
<!-- Lead presentazione -->
<section id="presentazione">
<div class="row">
<div class="col-sm-12">
<!--<h1 class="text-center"><small>Associazione per la Tutela dei Diritti Umani del Popolo Eritreo</small></h1>-->
<h1 class="text-center title">Associazione per la Tutela dei Diritti Umani del Popolo Eritreo</h1>
<h1 class="text-center leadTitle">Association in Defense of the Human Rights of the Eritrean People</h1>
<!--
<p class="lead text-center">
Association in Defense of the Human Rights of the Eritrean People
</p>
-->
</div><!-- /.col-sm-12 -->
</div><!-- /.row -->
</section><!-- /section presentazione -->
<!-- Progetti in evidenza -->
<header class="header-sezione">
<h2>Ultimi Articoli</h2>
</header>
<?
// get the term using the slug and the tag taxonomy
$term = get_term_by( 'slug', 'featured', 'post_tag' );
// pass the term_id to tag__not_in
query_posts( array( 'tag__not_in' => array ( $term->term_id )));
?>
<?php
if (have_posts()) :
// Start the Loop.
while (have_posts()) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part('content', get_post_format());
endwhile;
else :
// If no content, include the "No posts found" template.
get_template_part('content', 'none');
endif;
?>
</section>
</div>
<?php get_footer(); ?>
So what I want to do is that, for each post, the loop show only the date, the title and the beginning of my post (for example a specific number of character).
What can I do to obtain this result?
Tnx
first you should start reading the wordpress codex, that way you can know how wordpress works.
Now, the category.php template is trying to find other template part with this code:
get_template_part("content", get_post_format());
This code is looking for content-post format.php, in case that file doesn't exist, wordpress automatically looks for content.php and that file is the one you have to work.
You must find this file and you use the following functions
the_excerpt();
get_the_date();
the_title()
Now if you want to control the size of the excerpt, you can use this function inside of function.php.
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Bootstrap Carousel and Google Maps and Advanced Custom Fields

I'm building a wordpress site (here: http://dev.tps.entropii.com/contact-us/) that requires a full page width google map on the contact page. The Business has two addresses so they effectively need two maps with a means to switch between them. I'm using Advanced Custom Fields plugin to give the user the functionality to update/edit their addresses.
Here's the problem. In order to give the functionality to switch back and forth between the two maps I decided to put them inside a twitter bootstrap carousel. One slide for each map. This works as expected with one problem. The map that is contained within the inactive slide (e.g. the slide that doesn't have the class 'active' on page load), doesn't seem to fully load. If I put the maps side by side on the page without the carousel they load no problem.
Because I'm using advanced custom fields, the maps are being loaded using php. Here's the HTML/php from my template file:
`
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<!-- map 1 -->
<?php $map1 = get_field('map_1'); if( !empty($map1) ): ?>
<div class="acf-map" id="map1">
<div class="marker" data-lat="<?php echo $map1['lat']; ?>" data-lng="<?php echo $map1['lng']; ?>"></div>
</div>
<?php endif; ?>
</div>
<div class="item">
<!-- map 2 -->
<?php $map2 = get_field('map_2'); if( !empty($map2) ): ?>
<div class="acf-map" id="map2">
<div class="marker" data-lat="<?php echo $map2['lat']; ?>" data-lng="<?php echo $map2['lng']; ?>"></div>
</div>
<?php endif; ?>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#map-carousel" data-slide="prev"></a>
<a class="right carousel-control" href="#map-carousel" data-slide="next"></a>
</div>`
My suspicion is that because the inactive slides of the bootstrap carousel are set to display none, that the content isn't being loaded int he first place properly. However I'm completely stabbing in the dark. Can anyone shed any light on this?
Let me know if you ned any more info. Thanks,

Why does a wordpress know to use a specific template and how do I customize this?

Hello and thanks for reading. I am a .NET developer and don't know PHP (Although I am working on learning on the job) and what I am working on was made my consultants that we dont have contact with anymore. When a news post is clicked it appears to display using a template single.php. Followed is the code for this page:
<div id="marketBanner">
<div id="banner">
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/services-banner.jpg" alt="" />
</div>
<div id="breadcrumbWrap">
<div id="breadcrumbs">
<?php
if(function_exists('bcn_display'))
{
bcn_display();
}
?>
</div>
</div>
</div>
<div id="content">
<div class="left">
<h2><?php the_title(); ?></h2><br />
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="the_details">
Posted: <?php the_date(); ?> | View All News
</div>
<?php the_content(''); ?>
<?php endwhile; endif; ?>
</div>
Why does this page get used when a post is chosen? I want only a certain category of post to use this page and another category of post to use a different template. How do I achieve this?
You need to study the Wordpress Template Hierarchy # https://codex.wordpress.org/Template_Hierarchy#Single_Post_display
A template (PHP file) is looked for in this order (only on wordpress).
1 - single-{post_type}.php - If the post type were product, WordPress would look for single-
2 - product.php
3 - single.php
4 - index.php
In your case I would use single.php to create a template for the average post then specifically create a template for the one you want different using single-'post_type'.php
You can change the post type when creating a post.
Take a look at the Wordpress Template Hierarchy. It explains which templates get used and will probably be super helpful if you're just starting out with WP. You can use WP syntax to create category pages - but at the archive level - not the single post level.
To create separate pages based on post categories see here and below:
<?php
$post = $wp_query->post;
if (in_category(9)) {
include (TEMPLATEPATH.'/single-specific9.php');
return;
}
if (in_category(8)) {
include (TEMPLATEPATH.'/single-specific8.php');
return;
}
if (in_category(11)) {
include (TEMPLATEPATH.'/single-specific11.php');
return;
}

Link Genres in Advanced Custom Fields

I am using Advanced Custom Fields. I want to link the values (eg. thriller, suspense, etc.) of Genre custom field so that when the user clicks on one of the values they will get a filtered list of posts. For eg. when they click Thriller they will get all the posts in the Thriller category.
My code so far for the ACF is as follows:
<!-- Entry Content Start -->
<article <?php post_class('entry clearfix fitvids'); ?>>
<div class="inner-post">
<div class="cover">
<div class="post-image">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
</div>
<div class="custom-fields">
<?php the_meta(); ?>
<div class="ad">
<img src="http://lorempixel.com/160/600" alt="">
</div>
</div>
</div>
<div class="the-content">
<?php the_content(); // This is your main post content output ?>
</div>
</div><!-- /inner-post -->
</article><!-- /entry -->
Is there a solution to this?
You should create a page with custom page template. In this template you should pull posts based on the custom field passed via $_GET parameter. For example: $movies = get_posts(array('meta_key'=>'your_custom_key', 'meta_value'=>$_GET['genre'])); Then you should generate appropriate links to access this page, which should link to our custom page including genre in our $_GET variable. For example the page's slug is movies. Then our links will have the following structure: /movies/?genre=custom_field_value.

Categories