Jquery function working in Dev Console but not otherwise [duplicate]

As toscho pointed out, use jQuery(document).ready(function($) { … }); instead of $( function() { … }); Edit: Main problem is WP rich text editor escaping your html <script> tags. See https://codex.wordpress.org/Using_Javascript at the bottom of the page for a plugin-based workaround to turn off formating for specific posts/pages, allowing you to insert code. Alternately, add … Read more

WordPress from url get external source title

Here you go: class UrlToTitleConverter{ public function convert($Url){ $response = wp_remote_get($Url); if ( is_array( $response ) ) { $body = $response[‘body’]; $title = substr($body, strpos($body, ‘<title>’)+7); $title = substr($title, 0, strpos($title, ‘</title>’)); } return $title; } }

Help with a $wpdb MySQL Query

is this what you’re after? Using the “Relation” for the Meta Query, you can select multiple Meta Keys. You can change the “Compare” to any of the operations available for that function. (From the Codex) compare (string) – Operator to test. Possible values are ‘=’, ‘!=’, ‘>’, ‘>=’, ‘<‘, ‘<=’, ‘LIKE’, ‘NOT LIKE’, ‘IN’, ‘NOT … Read more

Font Awesome changing default WordPress Font

It was not Font-Awesome that changed the default WordPress Style. I also use Bootstrap. One file called scaffolding.less overrides the WordPress defaults with: // Body reset html { font-size: 10px; -webkit-tap-highlight-color: rgba(0,0,0,0); } body { font-family: @font-family-base; font-size: @font-size-base; line-height: @line-height-base; color: @text-color; background-color: @body-bg; } I just added this to my custom CSS File … Read more

How to add different text in each result of foreach?

You can use the wp_get_attachment_metadata() function which returns an array of data. I would add it to your code <?php $id = 51; $count = 0; $is = get_children(“post_parent=$id&post_type=attachment&post_mime_type=image&order_by=ASC”); foreach($is as $i) { $url = wp_get_attachment_image_src($i->ID, ‘full’); $attachementMeta = wp_get_attachment_metadata($i->ID); ?> <img src=”https://wordpress.stackexchange.com/questions/298553/<?php echo $url[0]; ?>” alt=”<?php echo $attachementMeta[‘image_meta’][‘caption’]; ?>”> <?php } ?> Read more … Read more

custom css for admin only

The code that you’ve tried already adds the role CSS class to the admin_body_class, which only affects the admin area/backend. Simply change the filter to alter the frontend body class body_class, eg. function wpa66834_role_admin_body_class( $classes ) { global $current_user; foreach( $current_user->roles as $role ) $classes .= ‘ role-‘ . $role; return trim( $classes ); } … Read more

Include a PHP file inside an array

Please Use Below code <?php $addcats = array(); ob_start(); require ‘custom_menu_addon.php’; $addCats = ob_get_clean(); wp_nav_menu(array( ‘theme_location’ => ‘menu-1’, ‘menu_id’ => ‘primary-menu’, ‘items_wrap’ => ‘<ul id=”%1$s” class=”%2$s”>%3$s<div class=”my-div”>’ . $addCats . ‘</div></ul>’ )); I’ve edited this answer after some research into the usage of this object array and put it in context with my code, works … Read more