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


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog


Channel Description:

WordPress › Support

older | 1 | .... | 339 | 340 | (Page 341) | 342 | 343 | .... | 413 | newer

    0 0

    Hi,

    I'm on WP 4.4 running with a Twentysixteen child theme. I'm displaying a custom menu in my sidebar using the Custom Menu widget. I want to show a menu item only for Authors, Editors & Administrators in the menu. To do this, I have added a function in my child theme's functions.php. The code for this function is as follows...

    function add_dynamic_link ($items, $args) {
    	if (current_user_can ('publish_posts')) {
    		if ($args->menu == 'Sidebar') {
    			$items .= '<li><a href="/teamspace">Teamspace</a></li>';
    		}
    	}
    	return $items;
    }
    
    add_filter ('wp_nav_menu_items', 'add_dynamic_link', 10, 2);

    However, this does not have the desired result. The menu remains unchanged. I tried debugging the function by adding the following line of code at different points in the function.

    echo $items;

    From the debugging process, I could gather that the filter is being executed. The problem seems to be that the execution flow is not entering the following "IF" construct...

    if ($args->menu == 'Sidebar') {
    			$items .= '<li><a href="/teamspace">Teamspace</a></li>';
    		}

    Now, there exists a custom menu called Sidebar on my install. So this should not be happening. I tried changing the $args properties being validated. Instead of $args->menu == 'Sidebar' I tried using $args->menu == 'menu-sidebar' (the ID of the custom menu) as well as $args->container_class == 'menu-sidebar-container' but none of them works.

    If I remove the problematic "IF" construct, the menu item shows in all the active menus on the site...not only the one in the widget.

    What could I be doing wrong and how do I rectify it?

    Thanks


    0 0

    I'm trying to hack a plugin to insert the category name of the post above the post title in a plugin/widget that displays three posts in a single row on the front page.

    The hack I tried is as follows, but while it worked on localhost it did not work on my live installation - this is the hack I tried to be added at functions.php:

    $count = 1;
    
    function custom_cat_before_featured_page_title($tc_fp_title_block , $featured_page_title = '' ){
    $o = get_option('tc_pro_fpu');
    
    global $count;
    
    if($count == 1){
    $value = 'one';
    }
    if($count == 2){
    $value = 'two';
    }
    if($count == 3){
    $value = 'three';
    }
    $value = $count;
    
    @$id = $o["tc_featured_page_{$value}"];
    @$categories = get_the_category_list( ", ", "", $id );
    $cat = '';
    if(!empty($categories)){
    $cat = ' <div class="customizr-fpc-category">' . $categories . '</div>';
    }
    
    $count++;
    return $cat.$tc_fp_title_block;
    }
    add_filter( 'fpc_title_block', 'custom_cat_before_featured_page_title' );

    The files related to the plugin/widget in the theme are as follows:

    http://pastebin.com/X210VebN
    http://pastebin.com/Q7ugkAJr

    I appreciate all help!


    0 0

    I am trying to get a feel for what are the best practices when needed to have reusable variables across theme files. Right now I a settings.php file that is being included within functions.php. In this file I would like to assign variables for global settings such as directory paths, module names, etc.

    Here is a very basic rundown of what I would do if I were to use globals:

    /**
     * Directories
     */
    $GLOBALS['theme-dir']	     = get_stylesheet_directory_uri();
    $GLOBALS['styles-dir']	     = $GLOBALS['theme-dir'] . '/dist/styles';
    $GLOBALS['scripts-dir']	     = $GLOBALS['theme-dir'] . '/dist/scripts';
    $GLOBALS['fonts-dir']	     = $GLOBALS['theme-dir'] . '/dist/fonts';
    $GLOBALS['fc-layouts-dir']   = 'templates/fc-layouts';
    
    /**
     * Layouts
     */
    $layouts = [
    	'blue-highlights',
    	'carousel',
    	'centered-content',
    	'custom',
    	'hero',
    	'list-items',
    	'product-highlights'
    ];
    
    $GLOBALS['fc-layouts'] = array();
    
    if( $layouts ) {
    	foreach( $layouts as $layout ) {
    		$GLOBALS['fc-layouts'][] = $layout;
    	}
    }

    Now to be safe I would probably need to "namespace" the global variable names, but I'm assuming that this is not the best way to do this and I know usually people want to stay away from using globals like this. Is there a cleaner way to achieve similar results using classes?


    0 0

    Ok, so I have setup and ran about 200 installations so far but this has me stumped and registering on the wordpress support forum, while I must say is wonderfully active.

    The goal is to recreate the look and feel of the backend taxonomy submission in the frontend. I am building two sites that need several custom fields build that include this functionality. One is a directory and the other is a job board. Both for specialty niches.

    Creating a custom non hierarchical taxonomy and Creating a field that submits tags to the backend is not a issue, the issue is retrieving the tags from the backend and displaying the autocomplete like the admin page has. I cannot find any plugins that have support for this, and documentation isnt very clear. I have build about 20 different functions and in the end none of them do it.

    Lets say we have a Taxonomy called Expertise, that has a about 120 tags already entered. It should auto complete for the user instead of them having to fully write them with no guidance. I would like to have the option to lock submissions for some of my custom taxs but not all.


    0 0

    I have an ifttt setup to post emails to a hidden account to new post of a certain category, but since the emails are actually a groupme conversation it would make more sense if they were comments. Is there an interface that could be used to add comments that ifttt or zappier could use to post comments as a authenticated user?

    I would be glad to work with someone and use my site for testing if someone could tell me how or create this function for me.

    Thanks!


    0 0

    I would like to remove "powered by wordpress" line. Last time I tried it messed up my site bad! Has anyone tried this recently?

    Also, (I just posted this in another thread but I think it's better suited here) I successfully removed the code so the search bar (magnifying glass icon) is gone but Ialso removed the code for the solid black right and left margins. What and where exactly do I place the code to replace that?

    mitchreedfiddlelssons.com


    0 0

    Hi guys,

    I'm apologise in advance if this is something that requires an easy to find fix, but I wasn't too sure how to phrase my question to find an answer.

    I'm using the Contact Form 7 plugin. I'm using the following code to pull a post with the contact form shortcode embedded.

    <?php
    			$post_id = 51;
    			$queried_post = get_post($post_id);
    			$title = $queried_post->post_title;
    			$excerpt = $queried_post->post_excerpt;
    			$content = $queried_post->post_content;
    			$thumbnail = $queried_post->post_thumbnail;
    			$feat_image = wp_get_attachment_image_src( get_post_thumbnail_id($queried_post->ID), '' );
    		?>
            <section class="page contact-us">
            	<div class="image" style="background-image:url(<?php echo $feat_image[0]; ?>)"></div>
                <section class="text">
                   <div class="inner">
                       <div class="column">
                            <h1><?php echo $title; ?></h1>
                            <h3><?php echo $excerpt; ?></h3>
                            <?php echo $content; ?>
                        </div>
                    </div>
                </section>
            </section>

    The plugin is working on the post's actual page, but it's not working when adding the above code to my index.php file (it only displays the shortcode). I've tried other plugins but no shortcodes are working when using this code. The client will need the ability to edit the post via the admin panel, so I cannot add the shortcode via PHP,

    What am I doing wrong?


    0 0

    For my plugin / CPT I would like to allow the user to order the articles like they can for pages. There is an option when registering a post type to indicate that it should support 'hierarchical' ordering of articles, like Pages do. However, there is a warning on the register_post_type codex page in relation to setting hierarchical to true:

    Be careful, when choosing it for your custom post type - if you are planning to have many entries (say - over 100), you will run into memory issue. With this parameter set to true WordPress will fetch all entries of that particular post type, together with all meta data, on each administration page load for your post type.

    https://codex.wordpress.org/Function_Reference/register_post_type#hierarchical

    I can easily imagine users of my plugin having more than 100 articles. Is this still valid? I see in Trac this ticket as fixed:

    Need Better Page Hierarchy Display Algorithm:
    https://core.trac.wordpress.org/ticket/15459

    Thanks!


    0 0

    I have added a new "Phone" field to the delivery address using the info here
    https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-3

    but the field is not coming through in the admin emails

    can you help me with this?


    0 0

    I've been having a problem with the login test cookie. Users have to log in twice because their first attempt yields this message: "Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress." Yet I can see in the dev console the TEST_COOKIE is set upon initially visiting wp-login.php. After the first login attempt, the login cookie is also set. Because of this, users are even able to bypass the verification math problem that appears during the second login attempt. Simply moving the setcookie directive higher in the wp-login.php page (right at the top in this case) resolves this issue completely.

    `//Set a cookie now to see if they are supported by the browser.
    $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
    setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure );
    if ( SITECOOKIEPATH != COOKIEPATH )
    setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );

    I see numerous complaints over several years about this issue on these forums and elsewhere with numerous recommendations for "fixes" (many of which involved forcing the TEST_COOKIE to be set earlier via functions.php hacks), none of which worked for me. Is there a reason the setcookie directive exists where it does? Is there any reason it cannot be set earlier in core?


    0 0

    Hi guys, hope everybody is doing fine.

    I have a very strange problem. First off I am using the X theme ( envato )with Cornerstrone PageBuilder. And I had a very weak pw for a long time, while the Site was in maintenance mode.
    Now my Problem : When I'm openening my Website, It also opens a Advertisement Website. These are always different links. I tried sucuri malware scan but no results. You got any Ideas or did you have this problem yourself ?

    greetings,


    0 0

    Hello,
    I had a sidebar widget working on my website. I use a php code plugin to use php on the sidebar. Anyway, I used the following code to list all the posts on my website in a dropdown menu. However, ever since the number of posts reached 750, the query will return an error:

    "Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0"

    When I lower the number of posts to show, the code will work. So is 750 a wordpress limit to help lower the site load? Is there a way to increase that? Thanks very much in advance.

    The code:

    <form action="<? bloginfo('url'); ?>" method="get">
     <select style="border-width:15pxborder-color:#c6c6c6; width: 77mm; background-color: #fff; font-family:Open Sans; font-size: 9pt;" onchange='this.form.submit()' name="page_id" id="page_id">
     <OPTION SELECTED value=""><b>--Tüm Destinasyonlar (Alfabetik)--</b>
     <?php
     global $post;
     $args = array( 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' );
     $posts = get_posts($args);
     foreach( $posts as $post ) : setup_postdata($post); ?>
                    <option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
     <?php endforeach; ?>
     </select>
    
     </form>
    <br>
    <center>
    <span style="font-size: 12px;">Şu anda sitede <b><?php
    $published_posts = wp_count_posts();
    echo $published_posts->publish;
    ?></b> destinasyon yer almaktadır.</span></center>

    0 0

    It's possible to change default url(domain) of new emoji j.script to my CDN.domain.com?
    How I can make it?

    code from wp-includes\formatting.php:

    } else {
    		$settings['source'] = array(
    			/** This filter is documented in wp-includes/class.wp-scripts.php */
    			'concatemoji' => apply_filters( 'script_loader_src', includes_url( "/js/wp-emoji-release.min.js?$version" ), 'concatemoji' ),
    		);

    0 0

    Have this code to display $unique_thelocation(meta value) as Tags and display each post foreach tag but its not displaying well. Not sure if my code is right.

    but i need help to display each post $unique_thelocation. Thank you!

    $place = get_category(get_query_var('cat'))->name;
    	echo '<div>';
    	query_posts( array ( 'category_name' => $place, 'posts_per_page' => 5 ) );
    	while (have_posts()) : the_post();
    
    		$args = array('location'=>'' );
    		$place = get_post_meta( get_the_ID(), 'place', true );
    		$place = wp_parse_args($place, $args);
    		foreach($place as $key => $value)
    		{
    			$thelocations[] = $place[location];
    		}
    
    	endwhile;
    	$unique_thelocations = array_unique($thelocations, SORT_REGULAR);
    	foreach($unique_thelocations as $unique_thelocation)
    	{
    		echo '
    <li><a>' . $unique_thelocation . '</a>' ';
    	  			if (have_posts() ) :
    				while (have_posts()) : the_post();
    					echo '<p>';  the_title();   '</p>';
    				endwhile;
    			endif;
    		echo'</li>
    ';
    	}
    	echo '</div>';

    0 0

    Hello Wordpress community,

    I'm using the 'wp_insert_post' hook to perform some actions when user inserts a new post.
    The post is a custom post type and it looks like, even though the general info related to the post is available in the global $post, the custom fields are still empty at that moment.
    Is there a better hook to do this?
    I need to perform the action when post is saved (new post, no updates) and be able to access all it's related fields. Accessing the $post values could be a good choice as well, but I don't need to filter them, just to take some decisions depending on data.


    0 0

    I want to set a condition for if post updated if is not author 1.
    For this, i added this

    <?php if (get_the_modified_time() != get_the_time() && ! is_author ( '1' ) : ?>

    But, this is not working. Please help!


    0 0

    I want to show client avatar and company logo in testimonial. But there is no such plugin that allow me to display two images. is there any way to display two images together?


    0 0

    hi there I am trying to switch between two datbase. I am using

    $wpdb->select('databasename');
    wp_cache_flush();

    however I am not getting any information and the theme is gone and only the text shows on this site.

    So I am stuck rigt now


    0 0

    What I want to do:
    I want a call to action widget related to the category of an post to appear in that category or post page. Say there is a blog article about X, a "Buy an X Now!" widget appears in the sidebar to that article.

    The way I know how to do this is create a widget for each category with the logic: is_category( 'X') || (is_single() && in_category('X')). This works well but we have about 10 different products (and growing) which means 10 different widgets.

    Is there a cleaner/more efficient way to do this? I was thinking something like a widget with some logic like !(is_front_page() || is_home()) (to check if page is an article or category page)

    and a php function which would get the category and modify widget content for that content.

    However !(is_front_page() || is_home()) still displays the widget on the About pages etc. Also I don't know how to immediately change the widget title with this method. The php function would also be run when it did not need to.

    In essence what I am looking for in psudocode would be
    (if is a category page || or an article){
    (get the article id)
    (modify the widget to display content based on ID)
    (display the widget)
    }
    else{don't display the widget}

    Any suggestions would be great. Thanks


    0 0

    Based on the path, I'm able to write custom routes to get the correct page, and set some custom variables... for example:

    If the route takes a URL in this format:

    http://example.com/products/:product_name

    And we hit this URL:

    http://example.com/products/baseball-glove

    And we're able to retrieve the page by doing:

    get_page_by_path('products/product');

    Right now, the original query initially searches for products/baseball-glove which returns the WP_Post object for 404 / Page Not Found, even though my subsequent query with get_page_by_path gets me the correct WP_Post object. How can I reset the global $post object to overwrite the current WP_Post and so that other plugins are able to use functions like the the_title()?


older | 1 | .... | 339 | 340 | (Page 341) | 342 | 343 | .... | 413 | newer