How to define category ID in an array?

As Geert pointed out, your current conditional will always be true. An if() construct needs to be fed an expression. You’re feeding it a valid array, so that’s true. Always. So far this is basic PHP, regardless of whether in a WP environment or not. As can be read in Chris_O’s comment if ( is_category(‘some-cat’) … Read more

How to create a cumulative posts and members count

Here is a very crude script I’ve knocked up to get what you are after: <?php require(‘wp-blog-header.php’); $posts = get_posts(‘numberposts=-1&order=ASC’); $posts_times = array(); foreach ($posts as $post) { $post_time = strtotime($post->post_date); $offset = $post_time % (60*60*24); $post_time -= $offset; $posts_times[$post_time]++; } $keys = array_keys($posts_times); $running_count = 0; $end_data = array(); for($i = $keys[0]; $i <= … Read more

How do I find the first item in the post array?

You can get first item using this code <?php global $post; $the_post_ID = $post->ID; $n = get_posts(); $i=1; ?> <?php foreach ( $n as $post ) : ?> <nav id=”postNav”> <ul> <li<?php if ($i){ echo ‘ class=”current”‘; $i=0; }?>> <a href=”https://wordpress.stackexchange.com/questions/88596/<?php the_permalink(); ?>” title=”<?php printf( esc_attr__( ‘Permalink to %s’, ‘twentyten`enter code here`’ ), the_title_attribute( ‘echo=0’ … Read more

Explode Array from Repeatable Custom Field

This is more of a PHP question than a WordPress question. Try to replace $temp = explode( “|”, $am ); with $temp = explode( “|”, $am[0] ); since $am is an array. You should also consider using isset() to check if the array items exists. Here is one idea: <?php $affman = get_post_meta( $post->ID, ‘affiliatemanager’, … Read more

Insert data into custom table from fetching $_POST values

if(!empty($_POST)) { $player_name = $_POST[‘first_name’]; $payer_email = $_POST[‘payer_email’]; $payment_gross = $_POST[‘payment_gross’]; $payment_date = $_POST[‘payment_date’]; $payer_id = $_POST[‘payer_id’]; $paypal_str = array($player_name, $payer_email, $payment_gross, $payment_date, $payer_id); print_r($paypal_str); global $wpdb; $wpdb->insert( ‘paypal’, array( ‘name’ => $paypal_str[0], ’email’ => $paypal_str[1], ‘amount’ => $paypal_str[2], ‘player_id’ => $paypal_str[3], ‘date’ => $paypal_str[4] ) ); } Remove the unwanted comma from the array.

PHP Use Declared array Variable inside already Declared Array

This is more a generic PHP question than anything to do with WordPress, but I’d suggest setting the value in the constructor: class test { public $basicCols; public $optList = array( ‘one’ => ‘One’, ‘two’ => ‘Two’ ); function __construct() { $this->basicCols = array( array( ‘title’ => ‘KEY’, ‘field’ => ‘slug’, ‘options’ => $this->optList ), … Read more