Skip to content

PHP Usage

Ethan Lin edited this page Nov 7, 2025 · 1 revision

PHP usage

Use AlphaListing programmatically when building custom templates or theme integrations.  

Most compatible approach

Call the shortcode from PHP and print the returned markup:

<?php
  echo do_shortcode( '[alphalisting]' );
?>

Pass a complete shortcode string with any attributes you need. This keeps behavior in sync with the documented shortcode options.

Direct template integration

If you prefer to bypass shortcodes, call the helper function directly in theme files:

<?php
  the_alphalisting( array(
    'post_type' => 'page',
  ) );
?>

The argument accepts the same parameters as WP_Query. Provide a single post-type slug or an array of slugs to include multiple post types:

<?php
  the_alphalisting( array(
    'post_type' => array( 'page', 'post' ),
  ) );
?>

When filtering by taxonomy, supply a tax_query configuration identical to what WP_Query expects.

Place these snippets inside PHP blocks. Omit the opening and closing tags if the surrounding template is already inside PHP mode.

Clone this wiki locally