How to Create Nextgen Custom gallery with album name - php

i am trying so long to making one normaly gallery useing by Nextgen gallery. but i can't make it yet. i found some way to show gallery thumbnail for speciy gallery and show album name but can't make that dynamicly and show together. bellow some code may be help
for show custom template file.
<?php
/*
Template Name: Gallery
*/
get_header(); ?>
<?php
$NextG = new NextGEN_Shortcodes;
echo $NextG->show_gallery( array("id"=>2,"template"=>"myshow") );
?>
<?php the_post_thumbnail(); ?>
<?php
if ( have_posts() ) while ( have_posts() )
{
the_post();
the_content();
}
?>
<?php get_footer(); ?>
for make custom nextgen gallery file
gallery-mytemplate.php
<ul id="slideshow">
<!-- Thumbnails -->
<?php foreach ( $images as $image ) : ?>
<li>
<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
<?php if ( !$image->hidden ) { ?>
<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
<?php } ?>
</a>
</li>
<?php endforeach; ?>
</ul>
what i want ?
actuly i want my gallery page will have all gallery name top always and if i click any gallery name then show that gallery. see http://www.evokephotoandvideo.com/2013-photo-gallery/ this url something like that. if can be possible also ajax load like ref. line then would be more nicer...

Simplest way for retrieving data from NextGen is to use NextGEN Gallery Database Class stored in ngg-db.php file. Open that file and there are all functions and explanations for taking the data directly from the database.
Example:
$NextG = new nggdb();
// get all galleries
$NextG->find_all_galleries();
// get single gallery
$NextG->get_gallery( 2 );
Results are arrays, to examine them use print_r or print_r2:
function print_r2($val){
echo '<pre>';
print_r($val);
echo '</pre>';
}
That way you can take id or slug from all galleries and create custom url's like http://www.evokephotoandvideo.com/gallery/slug.
Additional info:
WP Rewrite

Related

ACF Flexible Content - Image only displaying its link and not the designated thumbnail-sized image

I am trying to create my own Wordpress theme with assistance of Advanced Custom Fields. I have run into an issue that I cannot find the answer for.
I am trying to create a loop of images and text where the image is a thumbnail that when clicked shows full size through the usage of magnific popup. I can get the images to display statically without the lightbox effect but not with it. From the following code it only produces the link:
<?php
if( have_rows('content') ):
while ( have_rows('content') ) : the_row(); ?>
<div class="loopcontainer">
<?php if( get_row_layout() == 'text_with_image' ): ?>
<?php
$images = the_sub_field('text_image');
if( !empty( $images ) ): ?>
<a class="post-img" href="<?php echo $images['sizes']['blog-large'];?>">
<img src="<?php echo $images['sizes']['blog-small'];?>" class="img-fluid img-thumbnail">
</a>
<?php endif; ?>
<?php endif;
endwhile;
else :
endif; ?>
How would I go around getting the lightbox effect to work within this Flexible Content solution? And where am I going wrong?
Thanks!

Echo ACF media attachment custom field

I have an ACF gallery named documentation and also have set up a radio button custom field named image_size on the media attachments, so I can select from various image formats.
I would like to echo the selected image_size so I can use it as a class, however I cannot get it to show up.
Below is what I have put together based on the documentation, could someone please help point out where I am going wrong?
Thanks!
<?php
$images = get_field('documentation', $post->ID);
if( $images ): ?>
<?php
$documentation_class = get_field('image_size', $images['id']);
?>
<figure class="<?php echo $documentation_class; ?>">
<img src="<?php echo $images[0]["sizes"]["large"]; ?>" />
</figure>
<?php endif; ?>

Using Post Thumbnail with Fancybox

I'm trying to set my page so that when a user clicks the thumbnail of the current post, it expands in a Fancybox popup.
<?php
$featured_img_url = get_the_post_thumbnail_url($post->ID);
?>
<?php if ( has_post_thumbnail() ) { ?>
<div class="featured-image" data-fancybox="gallery" href="<?php $featured_img_url ?>"
<?php the_post_thumbnail(); ?>
</div>
<?php } ?>
This works, in that the image opens as expected when it's clicked. But when I click off the overlay, the thumbnail has disappeared. display: none has been added to it inline.
I have also tried wrapping the div in an <a> tag and using that, but this has the same outcome.
<?php
$featured_img_url = get_the_post_thumbnail_url($post->ID);
?>
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php $featured_img_url ?>" class="fancybox" data-fancybox="gallery">
<div class="featured-image bShadow">
<?php the_post_thumbnail(); ?>
</div>
</a>
<?php } ?>
I have other images on the page assigned with Advanced Custom Fields that work fine with Fancybox, so I'm assuming the issue is with how I'm trying to get the thumbnail image using php.
Edit: Here's a video of the current outcome: https://www.useloom.com/share/f525f4f0e4c642c8800e82532a99e326
It looks like you have not correct url for your featured link and it is treated as "inline" content instead of "image".
Anyway, you could follow this demo - https://codepen.io/fancyapps/pen/VGoRqO?editors=1010 - and use "trigger element" feature by adding data-fancybox-trigger attribute for featured link.

How can I embed a background video into my Wordpress theme using HTML5 and without using a plugin?

I'm attempting to add a background video to a wordpress website in place of the large image that is currently there.
I understand how to set up the video with HTML5 and CSS, but am not very familiar with php and am kind of lost on where to begin when it comes to writing a function to pull the video/s (wmp and mp4) from the media library and display them.
Any guidance on how to go about this would be much appreciated. Thanks!
I know that this is the part of the code that needs to be modified:
<div class="intro-block">
<?php if ( has_post_thumbnail() ):?>
<?php the_post_thumbnail('full'); ?>
<?php else: ?>
<?php
$image = get_field('global_intro_image', 'option');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" >
<?php endif; ?>
<?php endif; ?>
<div class="text-holder">
<div class="container">
<?php if( $title = get_field( 'title' )) : ?>
<h1><?php echo $title; ?></h1>
<?php endif; ?>
<?php if( $find_btn_link = get_field( 'find_btn_link' )) : ?>
<?php echo get_field( 'find_btn_text' ); ?>
<?php endif; ?>
</div>
</div>
</div>
It currently pulls the featured image for the page and displays it.
Any suggestions on where to begin?
Thanks in advance!
First you need to find out which part is calling the image. Looks like this part:
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" >
<?php endif; ?>
Then comment out this part or just remove this part of the code and replace if with video tag and style it so it looks just as you need.
Then if you need to be able to indicate videos from wordpress back end, than you need to create options page / or only add fields if you have theme options page.
https://codex.wordpress.org/Creating_Options_Pages
Even easier is to create options pages with ACF pro

If comment_author_link then put the link around avatar image

In the functions.php file for my theme the .commentslist shows a gravatar and if the user fills in a url in the comment form, you get a
comment_author_link()
Which prints a link with the name.
I want to put a link around the .avatar image IF there is a link. There is zip/zilch in the resources (https://developer.wordpress.org/?s=comment_author&post_type[]=wp-parser-function&post_type[]=wp-parser-hook&post_type[]=wp-parser-class&post_type[]=wp-parser-method).
It would be like this but this doesn't work:
<?php if ( has_comment_author_link() ) : ?>
<a href="<?php echo comment_author_url();?>" target="_blank">
<?php endif; ?>
<?php echo get_avatar( $comment, $size='75' ); ?>
<?php if ( has_comment_author_link() ) : ?>
</a>
<?php endif; ?>
But there is no such "has_comment_author_link" and I don't know how to create this.
Thanks!
Solved at Wordpress stackexchange: https://wordpress.stackexchange.com/questions/172152/if-there-is-a-comment-author-link-put-url-around-the-avatar-image/172156#172156

Categories