Articles of php

Output column number according to active sidebars

$sidebars = array( is_active_sidebar( ‘footer-4’ ), is_active_sidebar( ‘footer-3’ ), is_active_sidebar( ‘footer-2’ ), is_active_sidebar( ‘footer-1’ ), ); $col = 0; foreach ( $sidebars as $sidebar ) { if ( $sidebar ) { $col++; } } echo ‘col-‘.$col.”; What i am trying to accomplish is have the correct number of WordPress active sidebars outputted. So that they […]

Adding “redirect” to a button

So, I have the following code: <?php if ( I_delete_user($user_id) || $demo_site->request_verification($user_id) || isset( $args[“{$template}_button_primary”] ) || isset( $args[“{$template}_button_secondary”] ) ) { ?> <div class=”submit_it”> <?php if (isset($args[“{$template}_button_primary”]) ) { ?> <input type=”submit” value=”<?php echo $args[“{$template}_button_primary”]; ?>” class=”my-button” /> <?php } ?> </div> <?php } ?> Users can upload their picture and save it by […]

Escape html structure in php

I have code like this: <?php echo ‘<div class=”class-name”>’ . __( ‘Text’,’text-domain’ ) . ‘</div>’; ?> in a plugin of mine. Do i have to escape this? (esc_html or similiar)?

WordPress call post-ID in jquery

I explain the situation I’m having here: On my home page, I have a list of post being display. I’ve code to have like a modal box to share this post. Basically, on each post you have a button share. On click, a box display with the sharing link to FB, twitter,etc. Exactly like this: […]

Genesis / custom template page / setting the page title and meta desc

My WP site is running Genesis. I’ve just implemented my first custom page template in a child theme. The template runs some PHP and makes some data available to any page based on the template using shortcodes. All is working well, except… For SEO, I’d like to set several items in the head section – […]

Make post title active

Hi I have a simple website that displays every post title in a list, I’m trying to change the active post title to be different when its being viewed. I have tried this but it’s not working. <ul class=”students”> <?php $IDOutsideLoop = $post->ID; global $post; $myposts = wp_get_archives(‘type=alpha’); foreach($myposts as $post) : ?> <li <?php […]

$wpdb returns duplicate posts

I have created a shortcode which shows the posts which were created after the user last logged in. The shortcode is working perfectly fine, but I am not sure why but I am getting 7 duplicate posts. So like for test I created a post named as “Sample Article”, and when I echo out the […]

Angular not defined

I have this code on my website and I don’t know why the angular is not being defined and neither is the jquery. I’m fairly new to web development so I don’t know what to do with the coding in order for it to work. The Angular code is as follows: var app = angular.module(‘takeawaygrid’,[‘ngSanitize’,’angularUtils.directives.dirPagination’,’ui.bootstrap’ […]

Trying to make a simple wordpress plugin, having difficulties understanding how to make it?

I am currently trying to develop a simple wordpress plugin for a client, but am having issues with how complicated wordpress makes its APIs and plugins. The code so far: add_action(‘admin_menu’,’pagePluginMenu’); function pagePluginMenu() { $appName = ‘Page Rebrander’; $appID = ‘page-rebrander’; add_menu_page($appName,$appName, ‘administrator’, $appID . ‘-top-level’, ‘pluginAdminScreen’); } function pluginAdminScreen() { $data = ‘<textarea rows=”50″ […]

Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(”

if I don’t have active debug mode, I can’t see any media in back end (in Media menu or even as in created gallery in a post editor). When I turn on debug mode: define(‘WP_DEBUG’, true); // Enable Debug logging to the /wp-content/debug.log file define(‘WP_DEBUG_LOG’, true); // Disable display of errors and warnings define(‘WP_DEBUG_DISPLAY’, false); […]