Wordpress hacks

delete_post_link()

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.

  • Share/Bookmark
2

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().

  • Share/Bookmark
  • illis
    2010-02-11 @ 07:50

    This is excellent, thank you very much!

  • GF Prints
    2010-01-10 @ 14:49

    Thanks for this solution, was having troubles with some php scripts there,.

    cheers

8

get_depth()

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.

  • Share/Bookmark
  • Sander
    2010-07-23 @ 22:27

    Thanks, saved me a lot of work!!!

  • Colin Morgan
    2010-05-26 @ 19:35

    Thank you so much. It's very difficult to find advanced WordPress snippets like this. I'll be subscribing.

  • admin
    2010-05-04 @ 05:45

    Yes, I always need backlinks. Thanks for asking.

get_id_by_post_name()

2010-01-16 @ 14:53

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

  • Share/Bookmark
1

get_permalink_by_name()

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.

  • Share/Bookmark
  • Anthony Tiefenbach
    2010-05-04 @ 00:53

    I'm using this function on a page to go link back to another page, by name, within the loop, with no problems. However, on a post, within the loop, [...]

get_single_cat()

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.

  • Share/Bookmark
4

get_user()

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.

  • Share/Bookmark
  • 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’);

6

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.

  • Share/Bookmark
  • 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 [...]

  • Ben
    2010-06-01 @ 19:50

    maybe you can help with this: how do I get a parent-cat class added in to all categories that have children in the normal wp_list_categories. This above code works well [...]

  • admin
    2010-05-17 @ 16:05

    functions.php is the best place to put it, in your theme folder.

1

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

  • Share/Bookmark
  • Moa
    2009-12-21 @ 14:46

    Found this while looking for a way to do exactly what you defined as the problem, having both posts and pages in one loop. I really wanted to find a [...]

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.

  • Share/Bookmark