If Statement Post Formats: No post format selected

use get_post_format: $format = get_post_format(); if ( false === $format ) echo “no post format”; EDIT – an example using a switch statement: $format = get_post_format(); switch( $format ){ case “aside”: echo “aside”; break; case “chat”: echo “chat”; break; default: echo “standard”; }

Resize Image without cropping

When you upload an image to WordPress, the following happens: The file is checked and moved into the appropriate location in the uploads folder A post is created of type ‘attachment’ This post is filled with metadata from the uploaded file For each image size defined, a copy of the original image is created according … Read more

Pagenavi pagination via wp-query in functions.php showing same content for each page

Finally solved this with: function my_filter_where( $where=”” ) { global $wp_query; if (is_array($wp_query->query_vars[‘post_status’])) { if (in_array(‘future’,$wp_query->query_vars[‘post_status’])) { // posts today into the future $where .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘now’)) . “‘”; } } return $where; } add_filter( ‘posts_where’, ‘my_filter_where’ ); And: <?php $wp_query = array( ‘post__not_in’ => array(4269), ‘paged’ => get_query_var(‘paged’), … Read more

Handling an Ajax form submit

You should remove the link from the anchor tag: <a class=”button” href=”#” style=”background-color:white;color:black;”> <strong>Submit</strong> </a> Then your jQuery part should be: $(‘a.button’).click(function(event){ event.preventDefault(); //your ajax gets here: jQuery.ajax({ type:”post”, dataType:”json”, url: ajaxurl, data: {action: ‘submit_data’, info: info}, success: function(response) { alert(“Success”); } }); });

Adding Image Count to Multigallery

You can try function multi_gallery_shortcode($atts, $content=null) { extract( shortcode_atts( array( ‘pid’ => 0, ), $atts ) ); //format input $pid = intval($pid); // construct a post object dependent on the input value if($pid>0){ // query a post object $pobj = get_post( $pid ); }else{ global $post; // current post object $pobj = &$post; } // … Read more

Index showing source code

The problem was at .htaccess In the plugin w3 total cache I had enabled the option page cache, disk enache I switch to Disk basic. Then at the .htaccess it removed this code # BEGIN W3TC Page Cache core <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* – [E=W3TC_ENC:_gzip] RewriteCond %{HTTP_COOKIE} w3tc_preview … Read more

Use composer to load custom classes [closed]

Without more context from you, I can only assume and show you what I have done that works for me using PSR4 Autoloading. Example: Assuming that all my custom class directories and files is in ./inc folder In your composer.json, add this “autoload”: { “psr-4”: { “Inc\\”: “./inc” } } Inc is the vendor name … Read more