Wordpress hacks



2010-01-16 @ 14:55

I have created a function called ”Delete Post Link”. If you are logged in you will see a link which allows you to delete the current page or post, even without visiting admin.

  • Alexey Balin
    2010-11-30 @ 06:01

    I get this:

    Are you sure you want to do this?
    Please try again.

    May be need to add some other parametr, like "confirm=yes" ?


get_content() WITH formatting

2010-01-16 @ 14:55

Normally the get_the_content() tag returns the content WITHOUT formatting. I found out a solution in Wordpress core to make get_the_content() tag return the same content as the_content().

  • smotru
    2011-04-02 @ 19:00

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16387 bytes) in

  • riiii
    2010-10-31 @ 10:16

    hi, do you also know how to output the content without using wordpress functions directly out of the database eg using echo?

  • illis
    2010-02-11 @ 07:50

    This is excellent, thank you very much!



2010-01-16 @ 14:54

I created a function that returns the depth of a page or category. The depth is how many levels from the root the page or category in its hierarchy. The root level number is 0.

  • omid
    2013-07-08 @ 08:10

    very good peace of code :D
    as for idea i when i was using your code in my theme i face a situation that i have to show categorys only on [...]

  • http://tinyurl.com/newbwinch01500
    2013-01-27 @ 17:34

    I found this blog , “get_depth() - get depth of a page or category - Wordpress
    template tag / function | devdevote.com”, quite pleasurable and also it
    was a good [...]

  • Ivantus
    2012-01-06 @ 00:55

    Hi, great tutorial! I've got one question though. I'd like to show sidebar1 for depth1, sidebar2 for depth2 and so on. Any idea how to achieve this?
    At this point I'm [...]



2010-01-16 @ 14:53

The function converts a post / page name to a post /page ID.

  • appcropolis
    2012-09-16 @ 20:57

    This is very useful. I did not know about 'get_var'. This is a very quick way to get an specific property of a post/page without having to inspect a post [...]

  • Convert post name into post ID | Q&A System
    2012-08-05 @ 18:45

    [...] into a publish id. I’ve had a glance around on the internet and handled to locate this link http://world wide web.devdevote.com/content management systems/wordpress-hacks/get_id_by_publish_tit... which provides the next [...]

  • Aaron
    2011-02-25 @ 09:00

    Agree with Rama. Even get_by_postname would work...good for anti-collision in a plugin.



2010-01-16 @ 14:53

I created a function that returns an URL when sending a post / page name as an in parameter. Put the function into your functions.php in your theme folder.

  • Ootes
    2013-03-14 @ 13:15

    This is my approach for the same problem

    function get_permalink_by_title($title){
    $page = get_page_by_title($title);
    $pageID = $page->ID;
    $permalink = get_permalink($pageID);
    return $permalink;

  • AJ Clarke
    2011-05-27 @ 19:16

    This piece of code is great. But if you have made significant revisions to the page (like changing the slug) it gets messed up and shows a slug such as [...]

  • Ann
    2011-04-30 @ 00:44

    This solved a problem for me - many thanks!



2010-01-16 @ 14:52

I created a function that returns a value depending of the input type. Put the function into your functions.php in your theme folder.

  • vb078
    2013-08-16 @ 13:45

    quick finding a solution for linking get_category_link(get_single_cat('ID'))
    maybe you have some best one ?!

    I searching for multiple category display in the loop right now :)

    Thx you for reading me !

  • vb078
    2013-08-16 @ 13:38

    Hello :)
    I would like to make it with links (linked cat name), It's possible?
    Optionaly can you help with child cat names? (not single)

    Thank you so much
    (adding display-posts-shortcode categories)

  • patrick
    2011-03-09 @ 05:15

    thanks jen , its work for me , i have try it at my categorie page



2010-01-16 @ 14:51

Wordpress have a built in function called get_currentuserinfo. A global variable is set. It calls a function to get the user information. It then echos the username. The code is not as short and easy as it could be.

  • Harlow
    2010-08-04 @ 18:51

    Hi, this is a great piece of code, thank you! :)

    Since you say if we have any ideas we can write a comment and you’ll look into it, I have [...]

  • Chris
    2010-02-01 @ 03:31

    Thanks man... this was just what i was looking for...


  • admin
    2010-01-17 @ 14:32

    Try this:
    echo get_user(‘email’);


Wordpress have a ”bug”. It doesn’t add a current_cat_ancestor class to the wp_list_pages function. If you need it, you can use the code below.

  • matt mcinvale
    2012-01-04 @ 00:54

    much thanks for sharing this code, worked great with a 3.3.1 install i'm working on.

  • chai
    2010-10-24 @ 13:40

    Can modify with css tab navi manu?

  • Mike
    2010-07-01 @ 16:03

    I put the code in my functions.php file, then got this error: syntax error, unexpected ';', expecting ')'

    The error is in the line Phil is referring to above.

    I changed [...]


I want to use SQL-querys within the Wordpress loop and still be able to use the template tags. Here is the solution.

  • Andrej
    2013-01-12 @ 13:18

    Thank you for your post. This could be the right solution of my problem. BUT: what i shall do for this query: i want to show posts from category A [...]

  • Phoenix
    2012-05-14 @ 06:11

    Btw, this blog does not have a "Subscribe to comments" function, so if you respond, could you pls write to me. Thx!

  • Phoenix
    2012-05-14 @ 06:08

    Thanks Jens. After mucking about with so many WP_Query sites online, I just tried your very simple and powerful code. So tweakable!

    Question: do you know the "taxonomy" type for [...]


Get ID by post or page name

2010-01-16 @ 14:33

What I don’t like with wp_list_pages is that you can’t exclude or include pages by NAME. Only by ID is available. Here is the solution.

  • Shaun
    2012-01-18 @ 17:13

    Really helpful! You wrote a beautiful script for WP programmers.


  • Ivan
    2011-03-01 @ 09:44

    Yes Jens! Yes!
    Are many days I'm looking for this solution!
    It was impossible to find information about what you wrote.!
    From now on you have a new user who follows your website.
    Big [...]