1

I am trying to get some of the Miscellaneous shortcodes working properly on my website. In particular, I would like to use the pages shortcodes: [list-pages], [child-pages], [sibling-pages]. I am using a child of twentyfifteen with minimal changes to the template (background and font changes).

Here's the current behavior, with all of my plugins save for jetpack and akismet disabled, shortcode such as [youtube] and [archives] render properly. I can also create a shortcode in my functions.php file:

function test_shortcode() {return 'Working';}
add_shortcode('test_shortcode', 'test_shortcode');

That works properly as well. Using any of the pages shortcodes, however, returns just the bracketed shortcode. My website currently contains some test pages (2 parents, one child).

I have confirmed (through deactivation) that my plugins (save for Akismet) do not alter this shortcode behavior. I have also confirmed that the behavior is not affected by location (page/post/sidebar), post format (standard/aside), or template (twentyfifteen/twentyfourteen/twentythirteen). I have run out of debugging ideas at this point.

Note added in proof: Since the support page I linked above does not specifically mention another plug, I have assumed that these shortcodes were integrated into the current Wordpress platform and this plugin is no longer needed. Am I incorrect in this assumption?

  • WordPress.com platform is not the same as WordPress.org software, there are features of WordPress.com which do not exist in the self-hosted software. – Milo Dec 6 '15 at 16:31
  • @Milo Thank you for your comment; I did not recognize the difference. If you think that is a sufficient answer, please post it. Otherwise, I am happy to delete this question to minimize clutter on the site. – bobthechemist Dec 6 '15 at 16:50
2

As @Milo said, wordpress.com is a platform on its own, and everything available on wordpress.com is only available to sites hosted on wordpress.com. The jetpack plugin does however make some features available to self hosted sites but I'm not particulary sure which ones.

The shortcodes you are talking about is only available on sites hosted with wordpress.com, and not self hosted sites.

I have quickly rewritten a script I have recently done to look for filters and action in WordPress to get all shortcodes available to self-hosted sites. Here is the function

function get_all_filters_and_actions2( $path = '' )
{
    //Check if we have a path, if not, return false
    if ( !$path ) 
        return false;

    // Validate and sanitize path
    $path = filter_var( $path, FILTER_SANITIZE_URL );
    /**
     * If valiadtion fails, return false
     *
     * You can add an error message of something here to tell
     * the user that the URL validation failed
     */
    if ( !$path ) 
        return false;

    // Get each php file from the directory or URL  
    $dir   = new RecursiveDirectoryIterator( $path );
    $flat  = new RecursiveIteratorIterator( $dir );
    $files = new RegexIterator( $flat, '/\.php$/i' );

    if ( $files ) {

        $output = '';
        $array  = [];
        foreach($files as $name=>$file) {
            /**
             * Match and return all instances of apply_filters(**) or do_action(**)
             * The regex will match the following
             * - Any depth of nesting of parentheses, so apply_filters( 'filter_name', parameter( 1,2 ) ) will be matched
             * - Whitespaces that might exist between apply_filters or do_action and the first parentheses
             */
            // Use file_get_contents to get contents of the php file
            $get_file_contents =  file( $file );
            foreach ( $get_file_contents as  $key=>$get_file_content ) {
                preg_match_all( '/add_shortcode\s*(\([^()]*(?:(?-1)[^()]*)*+\))/', $get_file_content, $matches );

                if ( $matches[0] )
                    $array[$name][$key+1] = $matches[0];
            }
        }

        if ( $array ) {
            foreach ( $array as $file_name=>$values ) {
                $output .= '<ul>';
                    $output .= '<strong>File Path: ' . $file_name .'</strong></br>';
                    $output .= 'The following shortcodes are available';

                    foreach ( $values as $line_number=>$string ) {
                        $whitespaces = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                        $output .= '<li>Line reference ' . $line_number . $whitespaces . $string[0] . '</li>';
                    }
                $output .= '</ul>';
            }
        }
        return $output;

    }

    return false;
}

Because all shortcodes available to the frontend should be in the wp-includes file, we can run the function as follow: (NOTE I have tested this on localhost)

echo get_all_filters_and_actions2( 'E:\xampp\htdocs\wordpress/wp-includes/' );

which output

File Path: E:\xampp\htdocs\wordpress/wp-includes\class-wp-embed.php
The following shortcodes are available
Line reference 31       add_shortcode( 'embed', '__return_false' )
Line reference 60       add_shortcode( 'embed', array( $this, 'shortcode' ) )

File Path: E:\xampp\htdocs\wordpress/wp-includes\media.php
The following shortcodes are available
Line reference 1379       add_shortcode('wp_caption', 'img_caption_shortcode')
Line reference 1380       add_shortcode('caption', 'img_caption_shortcode')
Line reference 1490       add_shortcode('gallery', 'gallery_shortcode')
Line reference 2021       add_shortcode( 'playlist', 'wp_playlist_shortcode' )
Line reference 2270       add_shortcode( 'audio', 'wp_audio_shortcode' )
Line reference 2525       add_shortcode( 'video', 'wp_video_shortcode' )

File Path: E:\xampp\htdocs\wordpress/wp-includes\shortcodes.php
The following shortcodes are available
Line reference 59       add_shortcode( 'footag', 'footag_func' )
Line reference 72       add_shortcode( 'bartag', 'bartag_func' )
Line reference 80       add_shortcode( 'baztag', 'baztag_func' )
Line reference 89       add_shortcode($tag, $func)

Because the shortcodes picked up by the function in wp-includes\shortcodes.php is only samples in comments, we only really have the following shortcodes available by default on self hosted sites

  • [caption]

  • [gallery]

  • [playlist]

  • [audio]

  • [video]

  • [embed]

(NOTE: This is as at WordPress 4.4)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.