Adding a “Word” in php code

any word (html) you put between the single quotes will be echoed when you echo $output. so you can do this: $output .= ‘<div class=”dhvc-woo-view”>View: ‘; $output .= get_post_meta($post->ID, ‘pageview’, true); $output .= ‘</div>’; or $output .= ‘<div class=”dhvc-woo-view”>’; $output .= ‘View: ‘; $output .= get_post_meta($post->ID, ‘pageview’, true); $output .= ‘</div>’; it’s the same.

Non-array argument in array_merge()-function [closed]

Just make sure it’s definitely an array before you try to merge it: function minevalg_hent_innstillinger() { $defaults = array(); // define this somewhere; reference it here if ( is_array( $options = get_option( ‘minevalg’ ) ) ) $options = array_merge( $defaults, $options ); else $options = $defaults; return $options; }

main menu page redirects to user ID

One solution would be to create a page with a page template that gets all info based on the user ID. Then you can add that page to the menu. Something like this: <?php /* * Template Name: User Info */ get_header(); //Your code for getting the users id $user_id = ‘123’; //Output userinfo using … Read more

How to run ajax in WordPress Post?

I believe one of the comments should fix your issue given how you mentioned that the code works outside of WordPress, which does in fact appear to be a problem with your references to $ instead of jQuery. Also, i have written a post on this exact topic with step by step instruction, you can … Read more

Foundation modal in wordpress php loop

first, read this about query_posts. to answer your question- has_post_thumbnail() returns true or false, iterating over that in a foreach loop isn’t possible. I’ll guess that the reason why the same modal appears to be repeated is that you’re giving them all the same id, so the first one is always opened. Use the post’s … Read more

Result from wp_send_json adds line feed

Well that was tricky. This was the offending code that was generated a line feed to the response. add_action(‘wp_ajax_nopriv_display_event_info’, ‘DisplayEventInfoBox’); ?> <?php function displayStepHeader($isValid, $pos) I changed it to add_action(‘wp_ajax_nopriv_display_event_info’, ‘DisplayEventInfoBox’); function displayStepHeader($isValid, $pos) and all is well. I have no idea why that was an issue but how I tracked it down may be … Read more

Would it be possible to route WordPress Through an MVC Application

Well, it looks like my latest idea proved correct. Simply including the index file for wordpress was enough to get permalinks working for blog posts. $app->slim->notFound(function() use($app) { //to make pretty url’s work with turdpress, we must see if that request was intended for our blog route. if(strpos($app->slim->request->getPath(),’/blog/’) !== false){ include __DIR__ . ‘/../../blog/index.php’; }else{ … Read more