Questions tagged [code]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
110 views

How to write custom code on WordPress?

I need to write some function so that WordPress can get uploaded image from remote client tool, and found this one seems to fit my need: How do I set a featured image (thumbnail) by image URL when ...
Ben's user avatar
  • 3
1 vote
0 answers
175 views

Why namespaces are rarely used in WordPress plugins?

This is currently my impression. Many WordPress plugins I used do not use namespaces. On few occasions, on this website, I saw namespaces are good and should be used. Are there any drawbacks using ...
prosti's user avatar
  • 4,253
0 votes
1 answer
2k views

How do you find the logo code on theme file or where can I find the header theme file?

I am trying to find the header.php file and/or the code for the logo on any theme file. Under appearance- editor section of my website ( www.pithandsubstance.com ) I can only find function.php and ...
Hellops's user avatar
2 votes
1 answer
134 views

Admin Notices coding standard issue

I am having a bit of an issue right now with the VIP coding standards. I am trying to print out an admin notice as follows: add_action( 'admin_notices', function() { $class = 'notice notice-...
bretterer's user avatar
  • 123
1 vote
1 answer
22 views

code suddenly appearing from my tempate second loop

Recently a client of mine has asked his host to host to a 'special wordpress' server. In the process a whole pile of errors have cropped up. I have several templates based on this snippet of code. ...
maxelcat's user avatar
  • 151
2 votes
1 answer
6k views

How to implement Google reCaptcha without installing a plugin?

Wordpress noob here wondering how to include reCaptcha authentication in my login without a plugin? So far I have added the captcha div into the login using a hook: add_action('login_form','...
James Hamann's user avatar
1 vote
1 answer
1k views

How to avoid loading wp-load.php from external php scripts?

i use slim with wordpress. This worked flawlessly so far. Well almost. Once I changed to multisite I had to start fake creating $_SERVER variables faking a domain name. But it worked finally. What I ...
Toskan's user avatar
  • 504
0 votes
1 answer
1k views

How i can put $_GET codes in function.php?

if(isset($_GET["link"])){ $link = $_GET["link"]; header("Location $link"); } this my redirection codes. i put this code in function.php but not working. Example link: http://localhost/?link=http://...
Kenan's user avatar
  • 57
1 vote
0 answers
186 views

What is this code in my theme's footer.php causing chmod permission warnings? [closed]

I am stumped on this and can't seem to fix the issue. I removed the code, that didn't work as it came back. I tried looking throughout my theme's files and can't see anything else. Does anyone have ...
idiosyncratic's user avatar
3 votes
0 answers
38 views

Date/time limitation of posts where function must be executed

I have this piece of function in my functions.php file: function user_content_replace($content) { $sentences_per_paragraph = 3; // settings $pattern = '~(?<=[.?!…])\s+~'; // some punctuation and ...
Eager2Learn's user avatar
0 votes
1 answer
135 views

New theme HTML5 Support for Search in WordPress 4.4

I'm kind of new to creating my own themes with WordPress 4.x so I hope it's not too boring. In search.php I'm using this code: get_search_form () Also, I got this code in searchform.php <form ...
lowmatic's user avatar
0 votes
1 answer
1k views

wp_get_http has been deprecated. Use WP_Http instead

I use a premium plugin (for theme dev.) that has included the WordPress Importer plugin and I get a deprecated notice: "wp_get_http has been deprecated. Use WP_Http instead" But the WP_Http send me ...
Knott's user avatar
  • 454
1 vote
0 answers
208 views

What data validation we must use in different contexts?

Recently, my theme got rejected on Themeforest and one of the rejection issue is: Data Validation issues have been found in your theme. All dynamic data must be correctly escaped for the context ...
Knott's user avatar
  • 454
2 votes
2 answers
2k views

Notice: Undefined property: wpdb::$current_post What can be wrong?

I'm working on a WordPress site and I use the following code to show posts in two columns on archive and category pages: <div id="post-<?php the_ID(); ?>" <?php post_class( 0 === ++$...
Knott's user avatar
  • 454
1 vote
2 answers
606 views

How to fix a “globals” issue to avoid a rejected theme?

I submit a WordPress theme for Themeforest and one of the reasons for rejection was as follows: Globals should always be within a function or a class and should be used restrictively & only if ...
Knott's user avatar
  • 454
1 vote
2 answers
156 views

Cannot find the code for "Edit This" link in posts in a specific theme

I cannot for the life of me find the code for this particular item: Usually in other themes there's the link "Edit" on the front page and post page to directly go to edit the post in admin panel. ...
Grumpy ol' Bear's user avatar
0 votes
2 answers
4k views

How can I easily add code under the <body> tag without using hooks? [duplicate]

I need to trying to get the Facebook SDK for JavaScript code inserted just after the tag. What's the easiest way to do this?
Tom Hale's user avatar
  • 105
0 votes
1 answer
142 views

using wp enqueue style to create a CSS file specifically for a page template

I am trying to create a CSS file that only works for one page template. I am trying to do it using wp enqueue style but to no avail so far. I was able to get it to work (sort of) using the following ...
matthew's user avatar
  • 475
0 votes
1 answer
5k views

Creating custom post type with custom taxonomy and custom fields programatically

I need to create a custom post type. This post type will have a custom taxonomy. Also this post type will have custom fields. I dont want to use any plugins to do it, i want to include the creation ...
e4rthdog's user avatar
  • 441
0 votes
1 answer
331 views

Block IP Addresses using Code [closed]

Is there a way (which I am sure there is) to block IP addresses using code. I want the code to be in PHP so that I can put it in my child themes function.php to use for block some IP addresses. Thanks
matthew's user avatar
  • 475
2 votes
1 answer
68 views

Don't understand why theming is so strange and twisted [closed]

What I'm asking you here is not a technical question, but more a philosophical one. I firstly started developing themes for a small new cms that I also contributed on github that has a great potential,...
Giacomo Cerquone's user avatar
1 vote
1 answer
161 views

Where can i find wordpress auto update code flows?

I want to see how WordPress auto update works in code . which WordPress file or function performs auto core update? I have read http://halfelf.org/2011/how-the-wordpress-upgrade-works/ I have ...
Thamaraiselvam's user avatar
0 votes
1 answer
203 views

how to run a php code in widget?

I have a code to get all taxonomies and terms for a single post: $object_terms = wp_get_object_terms($post->ID, 'staff', array('fields' => 'all')); if ($object_terms) { echo '<p>' . ''...
nisr's user avatar
  • 71
0 votes
1 answer
33 views

How do I get access to the CSS Editor

I have a blog which is hosted by an ecommerce company who also host my website and online store. Because of this, they uploaded the theme I requested - Penscratch. I couldn't do it myself. I now want ...
Dan's user avatar
  • 1
0 votes
1 answer
285 views

Pull 'Popular Posts' within specific timeframe

I'm looking to display a weekly list of 'Popular Posts' on a site. Currently the list shows a 'Popular Posts' column but these are posts from no particular timeframe. It's displaying the most popular ...
Kelvin Farrell's user avatar
1 vote
1 answer
1k views

get_page_template returning nothing

I run this code in front-page.php as well in category-foo.php <?php echo is_page_template( 'front-page.php' ) ? "yes" : "no" ?> and get both times "no" printed i tried as well <?php ...
Toskan's user avatar
  • 504
0 votes
1 answer
905 views

Alternative functions for mysql_free_result and mysql_ping in wordpress functions

what are the alternative function for mysql_free_result and mysql_ping in WordPress functions , does WordPress function provides all the functions like php ? is it necessary to Free result memory for ...
Thamaraiselvam's user avatar
0 votes
1 answer
164 views

It possible to implement an adhoc php web application with wordpress?

I need to implement a web app in php and I wonder if it would be a good solution to use wordpress or just do it with external php code my web app: Has some panels with forms for the users to fill, ...
sergio's user avatar
  • 7
0 votes
2 answers
62 views

Remove Metaboxes

I try to remove metaboxes from non-admin for posts, pages, and add products page (WooCommerce), and this my code: // ciusART Remove Metaboxes add_action('admin_head', 'remove_metaboxes_for_non_admin')...
Dannie Herdyawan's user avatar
-2 votes
1 answer
87 views

Bad theme code - can you find the error?

This is what I have, and I need each of these blocks to pull the link, title of each blog post, and featured image they're supposed pull. Do you see the error? <div class="home-featured-block"> ...
user avatar
0 votes
2 answers
5k views

Accidentally deleted php code in Wordpress website [closed]

I have a website: www.convert2latex.com . While trying to remove the "continue reading", I accidentally deleted some code and updated it in the theme editor's functions.php. Now the website does not ...
Günal's user avatar
  • 101
0 votes
0 answers
673 views

Embedding code snippets in posts with indentation

I have a privately hosted blog using WordPress, and I am using the SyntaxHighlighter Evolved plugin for displaying highlighted code snippets nicely. I use the built-in editor in WordPress for writing ...
lysergic-acid's user avatar
16 votes
5 answers
45k views

Upload Multiple Files With media_handle_upload

I have a WordPress form plugin and I use media_handle_upload to upload the files and get there ids directly and attached its ids to the post as a meta date, I used the following to did that: The HTML ...
Engr.MTH's user avatar
  • 263
-3 votes
1 answer
970 views

Can you not edit the HTML and PHP of your WordPress without paying?

Sorry for the noob question. I'm new to WP. I'm not seeing where I can edit the HTML and PHP of my blog. I see a bunch of GUI options to change colors, etc. but nothing to change my blog's source ...
tim peterson's user avatar
0 votes
1 answer
3k views

how to add number value in front for variable [closed]

Hi there my question is very simple, is there a way by which we can add a value in the end of the variable a numeric value. like we have a variable $tota $tota1 $tota2 $tota3 each have different ...
Ubaid Rehman's user avatar
0 votes
1 answer
177 views

Widget Logic code for different PMP membership levels

I'm using both Paid Memberships Pro and Widget Logic plugins. In PMP, I set up 2 membership levels - one free ( id# = 3) , one paid (id# = 1) With Widget Logic, I'd like to have the custom sidebar ...
user3434928's user avatar
0 votes
1 answer
67 views

Google analytics won't work in wordpress

I have a godaddy host and I am using wordpress platform using simple key theme. In simplekey options - additionals it gives me option to add Additional Codes.. so I did add a code from google ...
James's user avatar
  • 1
0 votes
1 answer
318 views

Where do I add an action hook & callback in my theme?

Another answer suggests to Hook into the action wp_head but I am a newbie and I do not know where I am supposed to add the code provided. add_action( 'wp_head', 'wpse_91073_noindex' ); function ...
Mary Johnson's user avatar
1 vote
2 answers
28k views

How to display posts of specific category using a custom Query in WordPress?

Hi I want to display a specific category from a custom query in WordPress. My code works fine and it gets the latest 4 posts, but what I want now is to retrieve a specific category. My code is below ...
Jono's user avatar
  • 73
0 votes
2 answers
98 views

Code to Show for One post only in head

I want to add this code only for one post before </head> <link rel="alternate" hreflang="en-gb" href="http://abc.com"/> What code shall i use?
Sunny K. Ujjawal's user avatar
-2 votes
3 answers
1k views

CSS code for "inserting a custom post divider" after each post

I want to add a custom post divider to separate my posts. I'm using the Enfold theme in WordPress.org. I've searched for the answer to my question but I don't understand the coding language. I ...
Dori's user avatar
  • 11
0 votes
1 answer
995 views

WP List Pages - Add Title Attributes to Anchors

Using the default wp_list_pages() is there an easy way / filter to add title attribute to the anchors? Right now it just spits out the anchor with no title attribute but I would like to add it on ...
Howdy_McGee's user avatar
  • 20.5k
2 votes
0 answers
1k views

source code: WP_INSTALLING vs. WP_SETUP_CONFIG in setup-config.php

I am trying to make sense of the wordpress installation process. The file setup-config.php under wp-admin has the following. I want to know what the difference is between these two variables, why both ...
John Sonderson's user avatar
0 votes
1 answer
71 views

Add space to the end on a widget

I have a widget that when stacked with another the out put from my widget to the next sit on top of each other. I tried echo <br> but that gives me a fatal error. Is there any other code to add ...
user57348's user avatar
2 votes
1 answer
2k views

Open posts in editor in the 'Text' mode by default

I have a few posts where there are some code segments. When I try to make small edits in the post, it opens in the 'Visual' mode and all the non-alphanumeric characters (e.g. >) are converted to ...
Unos's user avatar
  • 121
3 votes
2 answers
1k views

Has anyone tried putting PHP ActiveRecord on Wordpress?

I have worked with Ruby on Rails and I was looking for some code that did something close to the wonderfull RoR's ActiveRecord. I stepped by this site. Its PHP-ActiveRecord! I found it amazing, and ...
Mauricio Moraes's user avatar
0 votes
1 answer
56 views

How can I optimize this code? [closed]

I have an Advanced Custom Fields Checkbox that I'd that I need to do some checks on. If a checkbox is ticked in the back end, it outputs an appropriate image on the front end. I've got some code that "...
yannibmbr's user avatar
2 votes
1 answer
1k views

How To Add Perfect Apostrophe And Quotation Mark In WordPress Posts?

I have a blog at www.exeideas.com where I am sharing codes snippet too. I am new to WordPress and migrated from Blogger. So now my all codes shared in posts stop working. When I check my codes then ...
Muhammad Hassan's user avatar
0 votes
1 answer
197 views

widget that will do shortcodes that user inputs

I have this widget that im working on and it allows the user to input a shortcode and it will display it in the sidebar. But its not working right. I can input the short code but it has no output. ...
MJ135's user avatar
  • 1
0 votes
1 answer
50 views

A good way to include snippets of code in both posts, pages and Event Manager Template files?

(I am not sure if I am phrasing this correctly, so please bear with me and be kind. ) I have a setup where the same information need to be included in both pages, and individual Events (Custom post ...
Anders Carlén's user avatar

1 2 3
4
5
7