Horje
Add_Action Wordpress Gallery to use Name Instead of Post ID - Wordpress Solution
I need to customize the native WordPress Gallery function so that I can display a gallery based on the name instead of the ID of the post it is attached to. A gallery plugin isn't an option. I found some useful info here: [[LINK href="http://wordpress.stackexchange.com/questions/43558/how-to-manually-fix-the-wordpress-gallery-code-using-php-in-functions-php"]][[/LINK]] and I see the wordpress file is at wp-includes/media.php But I'm not sure how to write the function / filter/action to make this work. Anyone have the answer?

Solution - 1

try this

<?php

    $post_title = 'my_post';
	$postData = get_page_by_title( $post_title, 'OBJECT' , 'post');
	$postID = $postData->ID;
	
	if(!empty($postID)) {

		echo do_shortcode('[gallery] id="'.$postID.'"]');

	}
	
	?>


Solution - 2

Do you want to show gallery based on the name of the album? ex:


<?php
$album_name = 'ABC';

$display = get_gallery_by_name($album_name);

// Or do_shortcode('[gallery name="'.$album_name.'"]');
?>





Wordpress

Related
Need Help With Syntax Error: syntax error, unexpected T_ECHO - Wordpress Solution Need Help With Syntax Error: syntax error, unexpected T_ECHO - Wordpress Solution
Modify wp-signup.php - Wordpress Solution Modify wp-signup.php - Wordpress Solution
deactivate links to single post view  - Wordpress Solution deactivate links to single post view - Wordpress Solution
Finding colour tones... - Wordpress Solution Finding colour tones... - Wordpress Solution
Custom headers and custom image sizes - Wordpress Solution Custom headers and custom image sizes - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8