How to query for pages/post depending on slug?

With a custom Page (post type page) and a custom Page Template, you can do it like so: In the templates, make a new instance of WP_Query which is used for querying the posts in either the Romanian or English language. In the query/function args for WP_Query and wp_get_archives(), use a custom parameter named lang … Read more

Replace word in “the_content” only for index.php

Few possibilities here: In index.php you find the_content() and replace it with: $content = get_the_content( $more_link_text, $strip_teaser ); $content = apply_filters( ‘the_content’, $content ); $content = str_replace( ‘]]>’, ‘]]>’, $content ); $replace = array( ‘autoplay=””‘ => ” ); $text = str_replace(array_keys($replace), $replace, $text); echo $text; Did you try putting that bit of code in index.php? … Read more

Custom post type permalink returns bad url

get_permalink() (which is used by get_the_permalink() and the_permalink()) returns the “ugly” URL if the post is not published, e.g. draft or scheduled, but you can use the following function instead which temporarily sets the post status to publish so that we’d get the pretty URL. function get_future_permalink( $id ) { if ( $post = get_post( … Read more

Show MySQL errors that occur when I excute $wpdb->insert()

This doesn’t answer your question directly, but the solution here is to validate the data before you chuck it at the database and pray. Sending bad data ‘down the line’ so that something else can check it and report back to you if it wasn’t what they were expecting is bad design. You don’t know … Read more

allow subscribers to see private posts without plug in

This can be added as a basic hook – function what-ever-youwantto-callthis() { $subRole = get_role( ‘subscriber’ ); //change the name of the user here $subRole->add_cap( ‘read_private_posts’ ); //allows the above to read posts $subRole->add_cap( ‘read_private_pages’ ); //allows the above to read pages } add_action( ‘init’, ‘what-ever-youwantto-callthis’ );