Skip to main content

Questions tagged [code]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
130 votes
4 answers
242k views

How to display SQL query that ran in query?

I have come across a function before that displayed the exact SQL code that was used. In a loop for example, but can't remember. Can anybody tell me that function?
Keith's user avatar
  • 1,546
65 votes
7 answers
19k views

Best collection of code for your .htaccess file [closed]

We have the Best Collection of Code for your functions.php file thread, so I thought that it might be useful to create a thread for our .htaccess files. AND PLEASE REMEMBER TO ADD ANY OF YOUR OWN ...
18 votes
1 answer
88k views

What is the meaning of %s, %1$s etc.? [closed]

From a Q&A Thread I've came to meet with some old things, but I'm afraid, I found myself in a condition that, I still don't know the meaning of them and don't know why to use them. %1$s - (found ...
Mayeenul Islam's user avatar
16 votes
5 answers
46k 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
11 votes
2 answers
9k views

Include WP_Query in my own PHP file?

I want to write a cronjob for myself. But I need to get access to WP_Query and the permissions to delete posts etc. My question now is, how can I include the WP_Query function to my own PHP file and ...
Jan's user avatar
  • 307
8 votes
2 answers
469 views

WordPress Internal @ Mentions

I'm looking for a way to link to author pages within one WordPress install simply by putting the @ symbol in front of a person's username in a post.... just like on twitter. Example: If the username ...
AndrettiMilas's user avatar
8 votes
2 answers
5k views

Return $post_id when DOING_AUTOSAVE?

I see the following pattern over and over, on this site and on other places: add_action( 'save_post', 'wpse14169_save_post' ); function wpse14169_save_post( $post_id ) { if ( defined( '...
Jan Fabry's user avatar
  • 30.5k
8 votes
2 answers
871 views

How to get a variable number of posts per post type on the main loop?

I'm looking for a way to balance the content at the homepage of my blog: the blog has a few post types like Poscasts, Videos and Blog and I'd like to have let's say 10 Posts on the homepage, but I'd ...
Jonathan DS's user avatar
7 votes
4 answers
27k views

What is this code in my theme's functions.php? if (isset($_REQUEST['action']) && isset($_REQUEST['password'])

This code appears in my theme's functions.php, also in child theme's. I've deleted it for two times but it comes back. What is it? if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['...
Topy's user avatar
  • 163
6 votes
5 answers
12k views

What theme is good for posting code? [closed]

I have my blog hosted at www.alphaot.com and I guess it's good enough. But problems arise when the lines of code get longer than 30 characters. The lines just wrap and get icky or something they even ...
user avatar
5 votes
2 answers
2k views

Create custom [sourcecode] shortcode, the right way?

What I want to do Sharing code in posts on WordPress is quite a pain with all the HTML escaping to take care of. So, I plan to enclose code in posts within a custom shortcode called [sourcecode], as ...
its_me's user avatar
  • 4,502
5 votes
1 answer
2k views

how to group custom post types

I wanted to know do i group my custom post types to appear together in a group in the wordpress back end menu bar like this below in the picture what code do i have to use in my functions.php so that ...
phantom.omaga's user avatar
4 votes
2 answers
4k views

How to create a custom button for the visual editor that adds 4 non-breaking spaces? (plugin or simple code)

To Wordpress' visual editor (TinyMCE), I would like to add a button that adds four non-breaking spaces when clicked, like this:      I found some plugins that add ...
its_me's user avatar
  • 4,502
4 votes
2 answers
234 views

How do i structure my theme folder to avoid one huge list of files

When working with a worpress site with lots of custom post types and lots of page templates, my theme folder is looking messy. What are the accepted best practices to organise code files in WordPress? ...
Will's user avatar
  • 352
3 votes
3 answers
2k views

Editing Source Code in Wordpress

I am a senior in a college computer science program, and therefore have a decent knowledge of code and several languages. However, I am doing a summer internship type program, and the company I am ...
Christian's user avatar
  • 133
3 votes
2 answers
1k views

Completely disable RSS feeds on WP 5.5.2 and show a 404 page instead of die();

I'd like to completely disable RSS feeds on my WP website. Can someone please guide me on how to throw a 404.php page and set the headers to 404, when someone types in https://example.com/feed/ here ...
api2_go's user avatar
  • 31
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
3 votes
1 answer
3k views

API integration with WordPress

I'm trying to integrate a 3rd party API with WordPress. I fear this is above my head. I was this code but I'm not exactly sure how to make is work in WordPress. Is it possible? $ch = curl_init(); ...
Jeces's user avatar
  • 31
3 votes
0 answers
39 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
3 votes
2 answers
922 views

Including Angle Brackets In Pre Sections

I am attempting to post some java code between pre tags but the angel brackets get removed. For example: private HashMap<String, HashMap<String, Integer>> featureCounts; becomes ...
David Williams'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
2 votes
3 answers
1k views

Pinterest Integration Using functions.php

I use a theme to build an portfolio. I´d like to add an pinterest "pin-it button" into the fuctions.php: Facebook, Google+ an Twitter were done, just the pinterest won´t work. Can´t found the the ...
ogni's user avatar
  • 582
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
2 votes
1 answer
1k views

Which theme foundry has clean coded themes, where code is poetry [closed]

I'm looking to find a theme foundry (ie. woothemes, elegant themes) that has themes that are very well coded; where "code is poetry". To be more precise, I'm looking for themes coded in "the wordpress ...
dwenaus's user avatar
  • 1,242
2 votes
1 answer
1k views

Can I run custom php on specific pages in wordpress?

I'm making a wp site as a new frontend to an in house system that I designed a while back. I want to be able to run custom php for grabbing different bits and peices of stuff from my database (mysql) ...
John's user avatar
  • 121
2 votes
1 answer
141 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
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
2 votes
1 answer
5k views

Successful or Error Message after running mysql code in functions.php

Just for this article, suppose there is a code that I want to run on my WordPress' functions.php file. It's a code to delete mysql table on my database. For example, here's the code: $wpdb->query( ...
Hardeep Asrani's user avatar
2 votes
1 answer
3k views

Adding custom styles to dropdown in editor

is it possible to add a custom style to the dropdown in the classic WordPress editor, say a div with the class of "fancywords"?
Gusto's user avatar
  • 87
2 votes
1 answer
3k views

Can I view my own wordpress php source code on my hosted web server?

OK so everyone must ask how to see the php source code sometime and I asked it to myself too. and yes I know it that the php is processed by the server before outputting it to web page, so with that ...
AutoBaker's user avatar
  • 151
2 votes
1 answer
3k views

Beautify WordPress HTML output without any plugins

Is there a simple (and without plugin) way to clean up the WordPress output of HTML? With a beautiful indentation of the code? I don't understand why, but my HTML output isn't perfect and it makes me ...
William Ode's user avatar
2 votes
1 answer
71 views

Where to save common libraries?

I have a multiple-site WordPress install. I have decided to centralize as many of my libraries as possible into one spot, for obvious organizational reasons, and in order to reduce bloating. Many of ...
Regis Zaleman's user avatar
2 votes
2 answers
1k views

Replacing the default content created while the site creation

How do you replace the default title for first comment? Mr WordPress on Hello world! I could not able to locate this in theme's comments.php file I want to edit the title 'Mr wordpress on Hello ...
Netizen's user avatar
  • 179
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
2 votes
1 answer
2k views

Adminbar Missing "Edit Page"

I'm encountering a problem that involves that my Admin bar doesn't show the "Edit Page" on pages I visit on my site. Instead for some odd reason it show "Edit Category" instead on supposed page. Does ...
Alexandros Christophoros Parat's user avatar
2 votes
1 answer
3k views

How do i get (unique) page name?

Like from the page of http://localhost/wordpress/about_us/ how do i get only the "about_us" ? Thanks
Umarfaruk M's user avatar
2 votes
1 answer
5k views

Connect Second Database to Wordpress

I am trying to connect a second database to my wordpress site so that I may ask for data from it and display it in a table on my site. I have tried multiple ways of doing so. I have tried to use php ...
Lella's user avatar
  • 25
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
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
2 votes
1 answer
551 views

Sublime Video: Playlist which gets all attached videos

I searched a way to automatically load all attached videos in a custom post type as SublimeVideo playlist. After some time I got it working and here I'll share the code with everyone who is interested ...
Philipp's user avatar
  • 119
1 vote
2 answers
19k views

Wordpress redirect all 404 pages to the Homepage

I want to redirect all 404 error pages on my WordPress site to the homepage, or to a specific page. Any advice?
Aadii Mughal's user avatar
1 vote
2 answers
1k views

VERY new to coding - keep breaking site trying to add to functions.php

I really appreciate everyone on this site who takes the time to answer questions here. I've learned a good deal already reading, but am sure I could learn even more if I could get past at least one ...
user avatar
1 vote
1 answer
957 views

Gist shortcode is not working

I freshly installed a brand new Wordpress for testing purpose as I am intending to refresh my current website. One of the requirement I have is to be able to embed code from Gist. Following the ...
Ucodia's user avatar
  • 113
1 vote
3 answers
1k views

Code Friendly Block Quotes

I have a self-hosted Wordpress Blog (located at http://www.dougmolineux.com/wp if you're interesed :) I put a lot of Code Snippets on there, because I'm a programmer. How do I make these "snippets" ...
Doug Molineux'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
1 vote
2 answers
611 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
157 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
1 vote
1 answer
1k views

Remove line breaks from <code>?

This code form HTML editor: <code>&#91;shortcode&#93; &#91;bar&#93;foo&#91;/bar&#93; &#91;bar&#93;foo&#91;/bar&#93; &#91;bar&#93;foo&...
Wordpressor's user avatar
  • 5,051
1 vote
3 answers
1k views

The custom logo, site title, and description doesn't appear at the same time

The problem I'm having is the custom logo, site title, and description won't appear at the same time. In image 1 below, you can see that with no custom logo, the site title, and description appears ...
Ricky Ritchey's user avatar
1 vote
1 answer
677 views

How to make this WP_Query run faster on a WordPress website?

This code is part of a custom WordPress homepage that shows the 7 most recent posts using WP_Query, and the first post has a custom html structurer, while the rest has another html structure. Then ...
mhweb's user avatar
  • 65

1
2 3 4 5
7