dynamically filter by category via sub-menu

What you seem to be asking is relatively easy with a filter on pre_get_posts. function set_post_type_for_category_archive_wpse_101930($qry) { if ($qry->is_main_query() && $qry->is_category()) { $qry->set(‘post_type’, ‘news’); } } add_action(‘pre_get_posts’,’set_post_type_for_category_archive_wpse_101930′); That will hijack your entire category archive. That is why I asked if you “want to force your category archives to only show posts from the news post … Read more

Target all images that are not the first attachment

I’m just modifying your code please check. Hope it will help. <?php $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID, ‘order’ => ‘ASC’ ); $i = 0; $attachments = get_posts($args); if ($attachments) { foreach ( $attachments as $attachment ) { if($i != 0){ $class=”fantome”; }else{ $class=””;} $imgarr = … Read more

How do I unserialize this?

Correct serialized string will be: a:1:{i:0;a:3:{s:4:”name”;s:56:”Song → Black Meen : “So Clean (feat. Dullaah Jin)””;s:4:”file”;s:93:”http://localhost/peace.worldwide/wp-content/uploads/2013/05/03-So-Clean-feat.-Dullaah-Jin.mp3″;s:9:”condition”;s:3:”all”;}} The second long string ( value of key “file” ) had incorrect lenght 98 which should be 93. You might ask why the first long string ( value of key “name” ) has lenght of 56. It looks like it … Read more

How to check “From Email” via WordPress before an email is sent

In wp_mail() there are filters to adjust from address: // Plugin authors can override the potentially troublesome default $phpmailer->From = apply_filters( ‘wp_mail_from’ , $from_email ); $phpmailer->FromName = apply_filters( ‘wp_mail_from_name’, $from_name ); However they don’t seem convenient for your needs because they don’t provide access to mailer object at the same time. You are probably better … Read more

MySQL database migration to WordPress

From technical perspective wpdb->prepare() essentially trickles down to escaping variables with either (depending on configuration) mysql_real_escape_string() or addslashes(). It’s not inherently more or less secure than any other properly implemented escaping routine. It is closer to specifics of WP and configuration it is aware off.