Are you the publisher? Claim or contact us about this channel

Embed this content in your HTML


Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog

Channel Description:

WordPress › Support

older | 1 | .... | 379 | 380 | (Page 381) | 382 | 383 | .... | 413 | newer

    0 0

    I've created a new editorial website for my company that uses WordPress as an uncoupled CMS and pulls all data via the WP REST API.

    For some reason, all the YouTube links in my posts are removed when I render the post content via Angular; I just get an empty set of p tags. Has anyone encountered this or found a fix?

    0 0

    I have 5 fields select in the search engine. I know how to make a request in one field

    $args = array('category_name' => 'name_category',
    'order' => 'date',
    'meta_key' => 'type',
    'meta_value' => $_POST['type'],
    'meta_compare' => '=');
    $event_query = new WP_Query($args);

    The problem is, I do not know how to expand a query to the 5 fields, which is not always the user chooses them. The user can leave one or two fields blank.

    0 0

    get_user_by returns object with pass too, if I use it, can it be used in anyway by attacker to do anything malicious? or having that pass isn't useful for him at all?

    0 0

    Need to move Sold out at last page of Woo commerce Pagination is any hook available

    0 0

    Hi there,

    I have a custom post archive displaying post and author meta at

    In the archive template I added a do_shortcode(); in the loop, specifically related to the "New Message" button which opens a dialogue to send a direct message to users. Clicking the button only triggers the dialogue for the first post display (though the button does show on all posts, which is even more bizarre). I tried this with a gravity forms shortcode as well and it only rendered the form in the first (top-most) post on the page.

    To simplify the question and perhaps make it more useful to others: Suppose I only wanted to show the post title and the shortcode. Would/should this be correct to make the shortcode fully work for all posts?

    <?php get_header(); ?>
        <?php $road_trips = new WP_Query(array(
        'post_type' => 'road_trip'
        )); ?>
        <?php while($road_trips->have_posts()) : $road_trips->the_post(); ?>
          <?php echo get_the_title(); ?>
          <?php echo do_shortcode('[shortcode]'); ?>
        <?php endwhile; ?>
        <?php get_footer(); ?>

    Here is the code for the actual shortcode as far as I can tell from the plugin source code:

    [Large code excerpt removed by moderator per forum rules. Please use the pastebin for all large code excerpts. It works better anyway.]

    The add_shortcode call, also in plugin file:

    add_shortcode(WPS_PREFIX.'-mail-post', 'wps_mail_post');

    However I've also tested it with a couple different shortcodes from different plugins. I have heard from another forum that the issue might be with the shortcode handler not being designed to work more than once per page. If there's a limitation with the shortcode handler, how can that be overcome to display multiple shortcodes per page?

    UPDATE: Replaced do_shortcode call with

    <?php echo wps_mail_post(); ?>

    and that's giving a missing argument error and also only working correctly (clicking "New Message" opens the message dialogue) for the top post at (the corresponding buttons on other posts only trigger page refresh and navigation to top of page).

    Will look into the $args but what's up with the functions only working for the first post / how to fix it? If the same issue is occuring with the function pasted in rather than using do_shortcode does that mean the issue is not with the shortcode handler after all?

    Any tips for getting shortcodes to work for each rendered item in an archive, and not just the first one?

    0 0

    is it possible to change the domainname with add_rewrite_rule (or somehow else)?

    Initial situation:
    "" and "" point to the same IP-Adress of my server.

    Under certain conditions I just want to change the domain name which is shown in the browser , but without redirect.

    Is this possible?

    0 0

    Quick question!

    I'm trying to figure out a simple way to let the built-in category count to also include pending posts, but haven't been able to find a good way to do so.

    The reason I need this is that I use an external tool that uses the WP-JSON API to push posts into Wordpress and includes the post count +1 in the title. However, if the last post is still pending, it uses the same number again. So if there are 5 published posts and 1 pending, the new post will still get "6" pushed into it, not "7" like it should.

    Any thoughts?

    0 0

    Hi there

    Not entirely sure this is the right forum, but here goes:

    I'm trying to display a WordPress page, identified by ID, from a PHP script. My code essentially looks like this:

    $page = get_post(1234);

    (Post ID 1234 does have post_type = page)

    This displays the content of page 1234 (that is, the text of the page), but not the complete HTML page.

    What am I doing wrong?

    Thanks in advance for any input on this.


    Morten Wittrock

    0 0

    On my website,, I have several photo galleries sorted by category. Clicking on a photo sends one to an individual photo post, and one can navigate between individual photos using arrow buttons. I'd like the site to remember which gallery the photo was accessed from, and for the arrow buttons to go to the next photo in the gallery (not the global post order). I don't want this to change the permalink, but to be treated as a temporary variable. Is there a good way to do this? I also wouldn't want to do anything that would preclude the use of caching plugin.

    For example, if you go to the "mammals" gallery and click on a photo, I'd like the arrow keys to navigate through the mammal category. (If a photo is accessed directly by link, the arrow buttons should navigate through all photos)

    Sorry if this is well-known; I am a beginner.

    0 0

    I have a custom post type 'road_trip' with taxonomy 'tripstatus' terms 'upcomingadventures' (id 10) and 'completedadventures' (id 11).

    I already added to functions.php a function to assign all new 'road_trip' posts automatically to the 'upcomingadventures' term using this:

    `function add_tripcategory_automatically($post_ID) {
    global $wpdb;
    if(!wp_is_post_revision($post_ID)) {
    $tripcat = array (10);
    wp_set_object_terms( $post_ID, $tripcat, 'tripstatus');
    add_action('publish_road_trip', 'add_tripcategory_automatically');`

    All 'road_trip' posts have a field 'end_date' (the end date of a road trip, in the future at the time of publishing a post). How can we automatically move posts from 'upcomingadventures' to 'completedadventures' when the timestamp of 'end_date' is less than the timestamp of 'now'? Hook into wp_init or wp_loaded? Adding to functions.php seems like the right approach but the part about needing to do it to all posts with term 'upcomingadventures' is throwing me off.

    I am thinking a wp query and a loop with the timestamp conditional inside it

    if strtotime(get_post_meta(get_the_id(), 'start_date', true)) > strtotime('now')

    and then a wp_set_object_terms() to move the post to 'completedadventures' when 'now' is later than 'end_date' would work?

    Not sure about the syntax details for the loop (or other approach) to call up all 'upcomingadventures' road trips to be tested for 'end_date' and then, where applicable, moved to the 'completedadventures' term.

    0 0

    I am trying to add check boxes on media page depending upon no of roles in the system and I have been able to do that like this.

    function add_custom_attachment_fields($form_fields, $post){
    	    $wp_roles = new WP_Roles();
    	    $roles = $wp_roles->get_names();
            $role_checkboxes = "";
           foreach ($roles as $role_value => $role_name) {
     	     $role_checkboxes .=	"<br/><input type='checkbox' value='$role_value' name='attachments[{$post->ID}][secured][]'  id='attachments[{$post->ID}][$role_value]' /> <label for='attachments[{$post->ID}][$role_value]'> $role_name </label>";
    		$form_fields["secured"]["label"] = __("Downloadable for");
    		$form_fields["secured"]["input"] = "html";
    		$form_fields["secured"]["html"] = $role_checkboxes;
    	   return $form_fields;
        add_filter('attachment_fields_to_edit', 'add_custom_attachment_fields', null, 2);

    And this is how I am trying to save the checkboxes values.

    function save_custom_attachment_fields($post, $attachment){
            if( isset($attachment['secured']) ){
                update_post_meta($post['ID'], '_secured', $attachment['secured']);
        	    delete_post_meta($post['ID'], '_secured');
           return $post;
        add_filter('attachment_fields_to_save','save_custom_attachment_fields', null, 2);

    What I expect is an array of values which have been checked but I am only getting one value in the array which is last checked value in the sequence.
    How can get the array of all checked values instead of just latest checked value.


    0 0

    Hi :) Could I ask you an advice please?

    I need to permit users to login with their stardard username, but that it could include a single quote. Currently I've added a custom filter that permits them to register with this special character in the username, but currently they aren't able to login with their username if it includes a single quote..

    function custom_sanitize_user( $username, $strict = false ) {
    	$username = wp_strip_all_tags( $username );
    	//$username = remove_accents( $username );
    	// Kill octets
    	$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
    	$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
    	// If strict, reduce to ASCII for max portability.
    	//if ( $strict )
    	//    $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
    	$username = trim( $username );
    	// Consolidate contiguous whitespace
    	$username = preg_replace( '|\s+|', ' ', $username );
    	return $username;
    add_filter('sanitize_user', 'custom_sanitize_user', 999, 2);

    Do you have any idea how can I do it please?

    Best regards
    - Chris

    0 0

    I'm trying to learn wordpress core and when I saw the compat.php file in wp-include I didn't understand why they checking for functions that exist in php and then if it not defined they define it. It does not make any sense to me. Why trying to write function that already exist in php core and why even to check if those function exist in the first place, if they suppose to be (I am talking about functions like mb_substr() ).

    I would appreciate any help.


    0 0

    I'm trying to patch up db cache reloaded fix to work on php7, and with the latest WordPress, but I'm having a small issue. So far, the issues I've encountered (and fixed) have been relatively minor (ancient) deprications that were removed in php7. However, now that I've changed these, I'm having a problem where php claims that wp-db.php is calling mysql_connect, which from all that I can tell should not be happening, as 1. without db cache reloaded fix, mysqli_connect works, 2. mysql_connect is not available, and 3. I've changed all instances of mysql_* to mysqli_*. The error I get is below:

    2016/05/08 06:04:15 [error] 9496#9496: *34288 FastCGI sent in stderr: "PHP message: PHP Fatal error:Uncaught Error: Call to undefined function mysql_connect()
    in /storage/websites/test/public_html/wp-includes/wp-db.php:1522
    Stack trace:
    #0 /storage/websites/test/public_html/wp-content/plugins/db-cache-reloaded-fix/db-module.php(206): wpdb->db_connect()
    #1 /storage/websites/test/public_html/wp-content/db.php(96): dbrc_wpdb->__construct('testblog', 'LiLMikERocks2', 'testblog', 'localhost')
    #2 /storage/websites/test/public_html/wp-includes/load.php(366): require_once('/storage/websit...')
    #3 /storage/websites/test/public_html/wp-settings.php(88): require_wp_db()
    #4 /storage/websites/test/public_html/wp-config.php(90): require_once('/storage/websit...')
    #5 /storage/websites/test/public_html/wp-load.php(37): require_once('/storage/websit...')
    #6 /storage/websites/test/public_html/wp-admin/admin-ajax.php(22): require_once('/storage/websit...')
    #7 {main}
    thrown in /storage/websites/test/public_html/wp-includes/wp-db.php on line 1522" while reading response header from upstream, client:,
    server: mywebsite, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", upstream: "
    fastcgi://", host: "mywebsite", referrer: "http://mywebsite/wp-admin/options-general.php?page=db-cache-reloaded-fix%2Fdb-cache-reloaded.php"

    Thanks for any help,

    0 0


    0 0

    My own plugin retrieves a few comments at the beginning of the post through my own WP_Comment_Query. I save these IDs so I can then alter the WP_Comment_Query request and not fetch these IDs.

    When I use the pre_get_comments hook to hide these already-fetched IDs, they are also hidden from my first query at the beginning of each post. It defies the point.

    add_action( 'pre_get_comments', $plugin_public, 'hide_the_comments' );
    function hide_the_comments( $comment_query ) {
        $comment_query->query_vars['comment__not_in'] = $the_ids_to_hide;

    How can we target the bottom request only, just like there is is_main_query() for the post loop?

    0 0


    Does anyone know how to add a custom metabox to the wordpress menu editor? I would like one similar to the custom link one but it would allow a user to enter a title and thats it so just plain text shows in the nav bar.

    Many Thanks

    0 0

    I need to disable this filter:
    $message = apply_filters( 'woocommerce_mail_content', $this->style_inline( $message ) );

    The style_inline() function exist in a class called WC_Email. So I tried:
    remove_filter("woocommerce_mail_content", WC()->WC_Email->style_inline());

    But it was a wild guess and it didn't work.

    Link to the full apply_filters code: here

    Link to the style_online() function: here

    0 0

    We have an external site (Wodify) publishing a blog post to our wordpress site via XML-RPC.php. Unfortunately I don't like the layout/content of the posts so I would like to alter it. Is it possible to intercept the post in the XML-RPC or is it possible to chain another call after submission including information that would allow me to alter it?

    I'm extremely new to PHP (Java Developer) so any code snippets or in depth descriptions of what I'm dealing with would be appreciated.


    0 0

    Sorry if Ive got this aroud my neck. Ive been using Umbraco where adding an heading, text field or a photo by placing a line of code in the layout is easy. Can I do this in my page ie insert headings and text into multipal columns and so on. Is there ref I can use to configure and copy in?


older | 1 | .... | 379 | 380 | (Page 381) | 382 | 383 | .... | 413 | newer