wordpress,function,wordpress-plugin,wordpress-theming,wordpress-plugin-dev , How to change custom admin menu?

How to change custom admin menu?


Tag: wordpress,function,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

I have created an admin menu in wordpress with these functions:

function list_menu(){
    add_menu_page( 'My Plugin', 'My Plugin', 'administrator', 'mylist', 'list_page', plugins_url('favicon.png'), 24);
add_action('admin_menu', 'list_menu');

function add_menu(){
    add_submenu_page( 'mylist', 'Add New', 'Add New', 'administrator', 'add_new_page', 'add_page');
add_action('admin_menu', 'add_menu');

But it create a menu with duplicate value in the menu like this:

enter image description here

Is there a way to let the menu like this:

=> My Plugin
===> All Posts
===> Add New


can you plz try this code.

function edit_admin_menus() {
    global $menu, $submenu;   
    $menu[24][0] = 'My Plugin'; // TO change admin parent menu
    $submenu['mylist'][0][0] = 'All Posts'; // To change child menu of "My Plugin" parent
add_action( 'admin_menu', 'edit_admin_menus' );



Wordpress function to effect only one (custom) post type, and not every post

I'm having an issue with a custom post type (WP Job Manager). I am using the following code in my functions file to 'add a default image to posts that have no image attached'. function custom_default_cover_image( $image, $args ) { global $post; if ( $image ) { return $image; }...

Can't understand this Javascript function (function overloading)

I'm reading Secrets of Javascript Ninja and came across an example that I cannot fully understand. This same example was cited by some other user here before, but their doubts are different than mine. Here is the example: function addMethod(object, name, fn) { var old = object[name]; object[name] = function(){...

PercentOfSum(fld, condfld) SSRS Equivalent

Crystal Reports has a built-in function PercentOfSum(fld, condfld) (documentation here). How can I achieve the same functionality in SSRS?

BeautifulSoup: Parsing bad Wordpress HTML

So I need to scrape some a site using Python but the problem is that the markup is random, unstructured, and proving hard to work with. For example <p style='font-size: 24px;'> <strong>Title A</strong> </p> <p> <strong> First Subtitle of Title A </strong> "Text for first subtitle" </p> Then it will...

How does ((a++,b)) work? [duplicate]

This question already has an answer here: What does the comma operator `,` do in C? 8 answers In the below block of code, I am trying to understand how the line return reverse((i++, i)) is working. #include <stdio.h> void reverse(int i); int main() { reverse(1); } void reverse(int...

Counting bytes received by posix read()

I get confused with one line of code: temp_uart_count = read(VCOM, temp_uart_data, 4096); I found more about read function at http://linux.die.net/man/3/read, but if everything is okay it returns 0, so how we can get num of bytes received from that? temp_uart_count is used to count how much bytes we received...

Foundation and Wordpress blank spaces

Anyone has an idea about the blank spaces that I'm getting in a while loop with wordpress using foundation framework? <div class="large-8 columns"> <?php query_posts(array('category_name' => 'revista', 'paged' => get_query_var('paged'), 'posts_per_page' => 9 )); ?> <?php while ( have_posts() ) : the_post(); ?> <article class="boletin large-4 columns" style="min-height:1px;"> <a href="<?php...

need wordpress plugin to show 3 type of different kind of text, image and 2 buttons

I have slider image on http://techturners.com/arman-badwal/ page in "featured work" section. I need plugin to create dynamic slider like image in section.I use many sliders like cyclone-slider but they show only title, description and image.

How to fetch the page id and use it for an image name

I am new in php. I want to make a condition for showing page id and set my image name is pageId and show this background image in my header banner. How to fetch page id use it fetching image for my banner background img. Here is my code: <div...

Calling function and passing arguments multiple times

I want to call the function multiple time and use it's returned argument everytime when it's called. For example: def myfunction(first, second, third): return (first+1,second+1,third+1) 1st call: myfunction(1,2,3) 2nd call is going to be pass returned variables: myfunction(2,3,4) and loop it until defined times. How can I do such loop?...

Can not link the author

I am Making a blog site. I want to show all posts of a user by linking with his/her user name. But it's not working. My code is by <a href="<?php get_author_posts_url(get_the_author_meta('ID'));?>"><?php the_author();?></a> What's wrong with it actually?...

Replace paragraph in HTML with new paragraph using Javascript

I am attempting to replace a p in my HTML doc with a paragraph created in Javascript. Once the page loads, two will be replaced with t. var two = document.getElementById("two"); document.onload = function myFunction() { var p = document.createElement("p"); var t = document.createTextNode("I am the superior text"); p.appendChild(t); document.getElementById("p");...

Is it possible to use $(this) in a function called from another function?

Sorry for the question title, I know it's not very well worded, but I couldn't really explain what I'm asking in a summary. I have a JQuery function tied to the click event of an element. For reasons that may well be flawed (other than making more sense to me...

Call known function (with parameters) in class whose name is defined by string variable

I have a bunch of classes of various names and each has a performLogic function that accepts a number of preset parameters (always the same): public final class DoSomeAction extends SetupAction { public void performLogic(param1, param2... I want a way where I can call it like this: String actionName =...

Wordpress log out using URL and redirect to specify page

I have one Wordpress installation . i need to log out the user without any indication user is coming from particular URL.Is it possible? My code: <?php if($_GET['logout'] == 1) { $redirect_to = current_page_url(); ?> <script> window.location.href="<?php echo wp_logout_url( $redirect_to ); ?>"; </script> <?php } ?> I am using above...

Woocommece login URL

I have a custom page for login in Wordpress with Woocommerce integrated, and need that when a user click on my-account page, instead of using the login form from woocommerce, redirect to my custom login url. my-account page only must be seen in case the user is logged in,else, I...

login with username or email in wordpress

I am working on login template...but I want to make login with username as well as email.I got code with for that but it is not worked,it is as follow: function login_with_email_address($username) { $user = get_user_by('email',$username); if(!empty($user->user_login)) $username = $user->user_login; return $username; } add_action('wp_authenticate','login_with_email_address',10,1); I already put action in 'authenticate'...

Add second single product page in Woocommerce

Is it possible to add a second single product page in Woocommerce? So basically when I am at the single product page I click the "next" button and I get directed to the same single product page with another template. So I just want to retrieve the same data on...

Creating complex queries with WP_Query in Wordpress

Here's a complex query which we've built using WP_Query. It should: Ignore post id 191 AND Select all posts with 'reihenfolge' <= 18 AND Ignore posts without a featured image AND Order them randomly Here is the code: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'meta_query' => array('relation'...

jQuery - Value in Function

My array: array.name = "Thiago"; array.date = "01/01/1990"; I want a function like this: function myFunc( array, fieldToCompare, valueToCompare ) { if( array.fieldToCompare == "Thiago" ) alert(true); } myFunc( myArray, name, "Thiago" ); is it possible?...

WooCommerce: How to display Category Name in single-product.php

How can I display the category name in single-product.php? In archive-product.php the code is: <?php woocommerce_page_title(); ?> but what could I use to show the category name in the single-product.php that belong to the category?...

Text-decoration/CSS causing text to move

I've tried a bunch of techniques to solve this. I've used float (left/right) and played with positioning (absolute & relative). None worked. Basically my navigation keeps moving when the the text decoration (font-weight: bold; in this case) is applied. I'm new to CSS and this is my first header- so...

wp_schedule_event hook sheduled but not working

I'm trying to trigger cron job from WordPress Plugin that I'm writing (It's gonna take all new Products and export them to CSV every day) so the problem is that when I'm put this code in functions.php all working great and the code is valid but from the plugin folder...

C++ need help figuring out word count in function. (Ex. Hello World = 2)

I'm figuring out the algorithm on this function and it keeps crashing at runtime, here's the code snippet: int wordCounter(char usStr[]) { int index= 0, punct= 0; while(usStr[index]!= '\0') //If it's not the end of the sentence if(usStr[index]== ' ') //If it finds a space index++; while(usStr[index]== '\0') //If it's...

How to exclude posts without featured images from custom post type WP_Query

We have the following WP_Query which collects all custom posts (except id=191) and lists them randomly: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'post__not_in' => array(191), 'orderby' => 'rand', ); $query_projekte = new WP_Query($args_projekte); How do we extend this to ALSO exclude all posts WITHOUT featured images? Thanks...

sum of Digits through Recursion

I am trying to make a recursive function which should return the sum of digits. The function should have only one argument. So far I have this; public int sumDigits(int n) { if(n%10 == n) // last digit remains return n; else{ int rightdigit; rightdigit = n%10; // taking out...

Changing font-size of
  • on wordpress

  • css,wordpress,html-lists
    I am adding some pages on a wordpress themed website. There is a table with 3 columns: 1st column will be the title (larger font). Since it looks better and editing is easier, I started using <ul> instead of <td> Even though it works fine on JSFIDDLE font-size on the...

    Update input number variable onclick

    I am trying to create a calculator style thing, where you put in how many years into a input, you hit submit and it gives you different results below without reloading the page. I have all the calculations working right now, but I just cant get the input number variable...

    How to skip a function

    I am learning python and trying to make a little game. So my question is can you define a function but skip it and use it later. EX. def func() print"1,2,3,4" func() def func2() print "counting" func() func2() How would I skip func but still be able to print it...

    Wordpress page can't continue due to this error

    I just faced this problem recently, I don't what causes it . But I need help fixing it. The error are : http://www.udesign.my/aaf4/wp-admin/admin-ajax.php?action=woocommerce_checkout Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://fonts.googleapis.com/css?family=century+gothic+:300,400 Failed to load resource: the server responded with a status of...

    Decremented value called in the recursion in Haskell

    So, I have this function that aligns the text to the left for a given column width. I have already fixed some of its problems, but I am unable to make it not use the decremented parameter once it is called, but to return to the starting value of n....

    ACF Multiple Map Markers

    I'm using Advanced Custom Fields and want to pull in the field called 'location' to display some locations on a map. How would i adjust the following code to display multiple markers from my location field? The format of the custom field is like so: echo 'Location: ' . get_field('location');...

    Run AJAX function on form submit button after javascript confirm() cancel

    I have a form where and AJAX function runs on form submission to make sure that the data in the form doesn't conflict with data in the database. If a conflict is found, the AJAX function pops up a confirm() box. If the user clicks "OK", the form is submitted....

    session value in javascript cannot be set

    I am quite new to javascript, I wonder why my session value in javascript wont be set to 1 even I tried. When call this function again, the value of the session will change again. My javascript code as below. <script type="text/javascript"> function Confirm() { alert(<%=Session["Once"]%> != 1); var value...

    Coding after Wordpress loop not showing

    I have been working on a custom archive page but I have run into some trouble. The pagination is shifting down into the footer area. I have gone through my code several times and I cannot work out why this is happening. If I remove the loop, the template works...

    CSS mystery: why the extra height in my div's?

    I'm just starting in on a new site and am getting extra space at the top of the div's I'm building for the home page. Using Safari's Web Inspector, I've eliminated any obvious padding or margins being responsible; but it's also seemingly telling me that the height of the div's...

    Stuck on Structs(c++)

    Okay so this is what Ive been asked to do "make a struct called Coordinate that contains the latitude and longitude of a point on the surface of the Earth. The struct should also store a label or name for the coordinate (e.g., “Calgary”). Both the latitude and longitude member...

    MySQL function with parameters syntax error

    I'm trying to convert this query to a MySQL function SET @v1 := ( SELECT count(id) as count FROM article_category where (title like "About Usd") or (title like "About Usd-%" and title regexp '[0-9]$') ); INSERT INTO `article_category` (`title`,`meta_data`,`meta_description`) VALUES ( IF(@v1 <= 0, "About Usd", CONCAT("About Usd","-",@v1) ), "ddddD",...

    WooCommerce seems to only orderby date and not price

    I am loading in variable products via a custom WP_Query $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'date', 'order' => 'desc' ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="product-node cat-beast-balls">...

    CSS disable horizontaly scrolling - Wordpress [on hold]

    Hi im working on a wordpress blog and have the following problem: http://www.catlovers.co/17-cat-reactions-that-sum-up-your-love-life/ If i resize the browser (X-Axies) to a minimum like surfing on a mobile device i am able to scroll to the right in the Contend section (hold down middle mouse button). How can i change my...

    Selecting and removing a html select option without selecting by index or ID, using vanilla JavaScript

    I need to remove an option on a select box, and I've figured out a potential solution in the code below, but it doesn't feel particularly 'safe' (if another developer decided to add an option to the backend, the option will re-appear). Is there a better way of achieving this...

    SQL average age comparison function returns null

    So, I'm working in MySQL, writing a function that averages the ages of women and men from a table and compares them, and returns which is greater. Dates are in the format of YYYY-MM-DD, and I'm using DATEDIFF(). The function appears to work correctly, but when I run the script,...

    Stopping condition on a recursive function - Haskell

    So, I have this function which aims to align the text on the left without cutting words(only white spaces). However my problem is that I cannot find a stopping condition of the function and it goes infinitely. f n "" = "" --weak condition f n s = if n...

    WordPress expanding grid with thumbnail

    I'm using codrops solution to display team members in an expanding grid: http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/ I was already able to change some code to display my post thumbnail in the grid preview. However, I want to display the same picture in full size in the expanded view. In the original version it...

    Wordpress Custom Post Type categroies

    I have a custom post type called STORIES. When a user adds a new STORY, I need them to be able to assign a category (or multiple categories) to the post so I can sort them later by category. To do this, I only want specific categories I assign to...

    Two language site in wordpress what i can do [on hold]

    I want to create 2 language site in word press. I am pretty new in word press. so what can i do. I will have 2 different theme for each language or do something else. The English is for left to right while Arabic is for right to left. So...

    How can I minimize this function in R?

    I'm attempting to write a formula that will determine a value of a that minimizes the function output myfun (i.e. a-fptotal). MWE: c <- as.matrix(c(.25,.5,.25)) d <- as.matrix(c(10000,12500,15000)) e <- 700 f <- 1.1 tr <- .30 myfun <- function(a) { b <- max(a-e,0) df <- data.frame(u1=c(c*b*.40),u2=c(c*b*.60)) df$year <- 1:nrow(df)...

    Wordpress End If Statements

    Apologies, PHP is not my strongest area so this might seem super easy to others. I am trying to implement a statement to say, when there is something in my WooCommerce Cart to show the cart. If there's nothing in the cart then show nothing. The code I have so...

    How to crop image from center using wp_image_editor

    I am working on WordPress plugin. In plugin the user upload images from meta field and in back end i use wp_image_editor for cropping and re sizing the images. The images re sized very well but on cropping the images not cropped very well. I give x-dimension 100 and y-dimension...

    JSLint won't recognize getElementById

    JSLint gives errors with simple function, running on brackets with JSLint. Javascript: function soundSorry() { getElementById("player").play(); } Error codes: 2 Missing 'use strict' statement. getElementById("player").play(); 2 'getElementById' was used before it was defined. getElementById("player").play(); Any ideas?...