Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter davidswain

    (@davidswain)

    Thanks Samuel B

    Not quite what I’m after those are related posts, I am looking for posts mentioned in the article

    Thread Starter davidswain

    (@davidswain)

    Should anyione be interested the solution is:

    if (!empty($full)) {
    
           $var = apply_filters('the_content', "[embed]" . $full . "[/embed]");
    
    		echo $var;
    
    	}

    where $full is the value of the url to be embed (eg https://www.youtube.com/watch?v=wLh6F7G7rPA) from a custom field

    Thread Starter davidswain

    (@davidswain)

    Thanks Michael

    Had a look through media.php but i dont really understand it!

    @jkovis

    That’s great, how do you then shows posts for the future? I.e. “upcoming” as opposed to past?

    Thread Starter davidswain

    (@davidswain)

    Doesnt work im afriad!

    I tried it with the following code:

    <?php echo do_shortcode('[-embed]https://www.youtube.com/watch?v=CSA657kxJQw[/embed]'); ?>

    and it just echoed the content

    remove the echo

    <?php do_shortcode('[-embed]https://www.youtube.com/watch?v=CSA657kxJQw[/embed]'); ?>

    rendered nothing

    <?php
    function formatBytes($bytes, $precision = 2) {
        $units = array('B', 'KB', 'MB', 'GB', 'TB');
    
        $bytes = max($bytes, 0);
        $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
        $pow = min($pow, count($units) - 1);
    
        $bytes /= pow(1024, $pow);
    
        return round($bytes, $precision) . ' ' . $units[$pow];
    } 
    
    function getDirectory( $path = '.', $level = 0 ){
    
        $ignore = array( 'cgi-bin', '.', '..' );
        // Directories to ignore when listing output. Many hosts
        // will deny PHP access to the cgi-bin.
    
        $dh = @opendir( $path );
        // Open the directory to the handle $dh
    
        while( false !== ( $file = readdir( $dh ) ) ){
        // Loop through the directory
    
            if( !in_array( $file, $ignore ) ){
            // Check that this file is not to be ignored
    
                if( is_dir( "$path/$file" ) ){
                // Its a directory, so we need to keep reading down...
    
                    echo "<h2>" . ucwords($file). "</h2>\n\n";
                    echo "<ul>\n";
    	                getDirectory( "$path/$file", ($level+1) );
    	        	echo "</ul>\n\n";
                    // Re-call this same function but on a new directory.
                    // this is what makes function recursive.
    
                } else {
                	$thefile = str_replace("./", "", $path) . "/" . $file;
                    echo "<li><a href=\"/" . str_replace("./", "", $path) . "/" . $file . "\">" . $file . "</a> " . formatBytes(filesize($thefile)) . "</li>\n";
                    // Just print out the filename
    
                }
    
            }
    
        }
    
            	    closedir( $dh );
        // Close the directory handle
    
    }
    
    getDirectory( "./download" );
    
    ?>

    I’m using this function in a template file, just set the directory you want to browse in getDirectory() function

    Thread Starter davidswain

    (@davidswain)

    anyone?

    Thread Starter davidswain

    (@davidswain)

    OK

    I have somewhat of a solution using some code i stole from eric martin it is:

    $img = "<img src=\"/image/galleries/" . $catnicename . "/" . $image ."\"  alt=\"" . get_the_title() . "\" />";
    
    		/**
    		 * New function that will display the navigation only if a previous or next entry exists
    		 * Hint: For entries, next == newer and previous == older
    		 */
    	function post_navigation() {
    			global $checkthelink;
    			$older = theme_previous_post_link('%link', '? %title');
    
    			if(strlen($older) > 0) {
    				$checkthelink = 1;
    			} 
    
    			return $checkthelink;
    		}
    
    		/**
    		 * Overrides the WordPress previous_posts() function in link-template.php
    		 * Modification: Changed echo to return
    		 */
    		function theme_previous_posts() {
    			return clean_url(get_previous_posts_page_link());
    		}
    
    		/**
    		 * Overrides the WordPress previous_post_link() function in link-template.php
    		 * Modification: Changed echo to return
    		 */
    		function theme_previous_post_link($format='? %link', $link='%title', $in_same_cat = TRUE, $excluded_categories = '') {
    
    				$post = get_previous_post($in_same_cat, $excluded_categories);
    
    			if ( !$post ) {
    				return;
    			} else {
    			$format = 1;
    
    			return $format;
    			}
    		}
    
    		post_navigation();
    
    	if ($checkthelink != 1) {
    		echo $img;
    	} else {
    		previous_post_link('%link', $img, TRUE);
    	}

    thats as small as i can get it but im sure it could be more efficient, anyone can they help?

    David

    Thread Starter davidswain

    (@davidswain)

    Thinking about it could i do another query_posts() with offset within the main loop get the permalink?

    Forum: Fixing WordPress
    In reply to: Gallery use
    Thread Starter davidswain

    (@davidswain)

    Ahhhh

    I think i have discovered why (in sort) it because im using /%category%/%postname%/ as my permalink structure. Im not quite sure why that adds attachement and using day and name permalink structure doesnt but im getting closer…

    Thread Starter davidswain

    (@davidswain)

    Iridiax i see *sound of penny dropping*

    thank you ever so much for your help, i’ll have a rethink.

    Thread Starter davidswain

    (@davidswain)

    Im not being clear.

    I would like to have urls like:

    https://www.example.com/tag/shopping-and-f***ing/

    Thread Starter davidswain

    (@davidswain)

    Well i have sen urls with characters like * in

Viewing 13 replies - 1 through 13 (of 13 total)