Questions tagged [code]

The tag has no usage guidance.

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

Anchor Text code string is automatically modified by WordPress

I have created an ad for a merchant wanting to rent ad space on my website home page. After creating the ad, (anchor text and pic/graphics with embedded hyperlink) the merchant has requested I remove ...
DPano's user avatar
  • 1
129 votes
4 answers
238k 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,536
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
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.4k
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
85k 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
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
858 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
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,491
4 votes
2 answers
231 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
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
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
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
1 vote
2 answers
416 views

write in functions.php

i just want this code to be added in my functions.php, so that it will directly display after my post ends currently i am adding this code to my single.php, but i want to add this is in functions.php, ...
Niraj Chauhan'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
7k views

Copyright info change in Theme Child PHP

Below is the file where the information is pulled from. I have tried adding the /inc folder to the child theme and adding the template-tags.php with the changed but this does not make any affect. /...
Harvey's user avatar
  • 53
1 vote
1 answer
4k views

Add footer.php to Wordpress child theme

So I am using the theme of 'Mesmerize' I have created a child theme but want to change some of the footer php within the child them so when there is a theme update the changes done reverse. This is ...
Harvey's user avatar
  • 53
1 vote
3 answers
4k views

Wordpress is converting & to & inbetween [code] brackets

I installed a syntax highlighter plugin so I could post and highlight code snippets. My problem is wordpress is converting special characters in my code (e.g. from & to &), when I really ...
Sean's user avatar
  • 11
1 vote
2 answers
131 views

How can I include PHP-Code to my post?

I would like to use PHP in some posts. These posts should look like normal posts, be in the archive and categories like normal posts an have tags. I don't need PHP in every post, but it would be ...
Martin Thoma's user avatar
0 votes
2 answers
4k views

I want to remove the links from the term list returned by get_the_term_list

I want to keep this category title on my pages, but I don't want it to be a link. <?php echo get_the_term_list( get_the_ID(), 'portfolio_cats', ' ', ' , ', ' '); ?> Can anyone help? Thanks
Toronto's user avatar
0 votes
2 answers
883 views

How to link to a alternative page in CSS

I have a wordpress site and I want to be able to completely change a page that is displayed based on the browser size in my Custom CSS, so that if it is over 1500 pixels it loads a completely ...
JASON DENNING's user avatar
0 votes
1 answer
443 views

Formatting <code>?

I have serious trouble displaying code blocks in my theme. I want to display something like: <something> <something-else> Content </something-else> </...
Wordpressor's user avatar
  • 5,031
0 votes
4 answers
414 views

Problem with <code> tag

Where you can see it: http://themeforward.com/demo2/functional-codes The first button is my code, as it should appear. The second button is within <pre><code></pre></code> ...
AndrettiMilas's user avatar