How can i display gallery shortcode output under Post text

The do_shortcode() function returns the shortcode output as a string, which can be appenend to the post content with the_content filter. Here’s an example how to do that, // add filter with late priority add_filter(‘the_content’, ‘my_post_attachments_gallery’, 99); function my_post_attachments_gallery($content) { // modify only published posts if ( is_singular( ‘post’) && ‘publish’ === get_post_status() ) { … Read more

How to move all theme templates into a subfolder WP

Not easy to do. You can create redirect template and assign templates based on page ID <?php if (is_page(‘629’)) { include(TEMPLATEPATH . ‘/pages/homepage.php’);} elseif (is_page(‘186’)) { include(TEMPLATEPATH . ‘/pages/generalpage.php’);} else { include(TEMPLATEPATH . ‘/pages/defaultpage.php’); } ?> See this for more details

Why does this snippet in a blog post make WordPress crash?

And of course after I ask the question, I find the solution… Apparently it’s caused by a trigger happy Mod_Security. WordPress: 503 Service Temporarily Unavailable when Posting New Posts or Modifying Existing Posts Adding these lines to the .htaccess file makes it go away nicely: <IfModule mod_security.c> SetEnvIfNoCase Request_URI ^/wp-admin/(?:post|async-upload)\.php$ MODSEC_ENABLE=Off SetEnvIfNoCase Request_URI ^/xmlrpc\.php$ MODSEC_ENABLE=Off … Read more

How to make number of blog posts a custom field?

It might actually still work, but the syntax is currently wrong (you have a PHP opening tag inside another opening tag). And you can assign the value of the custom field to a variable using the get_field function. What if you try this? <?php // assuming your ACF name is ‘number_of_posts’ $numposts = get_field(‘number_of_posts’); $args … Read more

Displaying Latest Posts on a Page

You can modify your post template (usually index.php, but depends on your theme) to: check if the current request should response those posts add a segment which will query the database to retrieve the posts you wish echo the post title and excerpt as you wish The following code will query the database and return … Read more