Affichage des articles dont le libellé est Newest questions tagged wordpress - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Newest questions tagged wordpress - Stack Overflow. Afficher tous les articles

lundi 5 octobre 2015

PHP WordPress Plugin - How to display a div on the static homepage only?

This is my first time building a plugin for WordPress. I got the basics down but now I am trying to display a div on the bottom right corner, more like a small pop-up on the bottom right side of the front page only. The PHP code that I've uploaded did not work, it kept crashing my website.

Where is my mistake?

Please explain your answers. Thank you!

Code:

<?php
/*
Plugin Name: My First Plugin
Plugin URL: http://ift.tt/1VC3cMl
Description: An awesome facebook popup plugin that will amaze you!
Author: Martin
Version: 1.0
Author URL: http://ift.tt/1VC3cMl
*/
add_action('admin_menu', 'myfirstplugin_admin_actions');
function myfirstplugin_admin_actions() {
    add_options_page('MyFirstPlugin', 'MyFirstPlugin', 'manage_options', __FILE__, 'myfirstplugin_admin');
}

function myfirstplugin_admin()
{
?>
<style>
    .wrap { 
        width:100%;
        height:auto;
        }

    .popup {
        position:fixed;
        bottom:0;
        right:0;
        width:325px;
        height:200px;
        background-color:#09f;
    }
</style>


    <div class="wrap">

    <h1>Hello World!</h1><br>
    <h4>Hope you like my awesome popup!</h4>

    </div>



<?php if(is_front_page()) {
        <div class="popup">Testing Div Tag On The Bottom Right Corner...</div>
    }
?>
<?php
}
?>



via Chebli Mohamed

How do I change the name of this sub-directory?

Long time listener, first time caller. Thank you all for your consideration. If you check out my dev site here: http://ift.tt/1GsZ36m

You'll see i'm using a wordpress theme that is built for lawyers/attorneys and not accountants like I am trying to pull off. How can I switch the "attorney" part in the URL path to something more general like "team" or "accountant"?

I'm okay if the back-end part (i.e. the Wordpress Dashboard functions) are labelled "attorney" (as they do now), as long as the user-side doesn't show "attorney".

Any help? I'm not a trained back-end developer, as you may be able to tell. Thanks!



via Chebli Mohamed

How to make a custom page in Wordpress

Hi I'd like to create a totally custom page in wordpress where I'd add a lot of php code so I would prefer not to create it as a wordpress 'Page', but as a file 'filename.php' in my theme directory. Of course in that page I need to include wp functions and stuff and I plan to do it with require_once("../../../../wp-load.php");.

My problem is, how do I set the header info for a custom page like that (title, meta description etc..) and how do I add a rewrite rule to make it reachable like "website.dom/pagename". Thanks in advance for any answer, and even if you tell me that the best way is to use wordpress default "Add New Page", I'd prefer not to use any script to insert php code in the page, thanks.



via Chebli Mohamed

How to include authors (users) in the results for the native WordPress search?

Does anyone knows a way to include authors as part of the search results in the native wordpress theme without plugins?

Thanks



via Chebli Mohamed

Exclude page from a wordpress sitemap

I came across a tutorial on the internet for creating a sitemap in WordPress. It does what I want - it lists all pages and posts on the website however I was wondering if it was possible to exclude a page from the sitemap. In this case I want to exclude the sitemap link. Is it possible to do this? I have included the code for the sitemap below.

<?php
/*
Template Name: Sitemap
*/

get_header(); ?>


<?php if ( have_posts() ) : while( have_posts() ) : the_post();
        the_content();
endwhile; endif; ?>

<h2>Pages</h2>
<ul>
<?php
// Add pages seprated with comma[,] that you'd like to hide to display on sitemap
wp_list_pages(
  array(
    'exclude' => '',
    'title_li' => '',
  )
);
?>
</ul>

<h2>Posts</h2>
<?php
// Add categories seprated with comma (,) you'd like to hide to display on sitemap
$cats = get_categories('exclude=');
foreach ($cats as $cat) {
  echo "<ul>";
  query_posts('posts_per_page=-1&cat='.$cat->cat_ID);
  while(have_posts()) {
    the_post();
    $category = get_the_category();
    // Only display a post link once, even if it's in multiple categories
    if ($category[0]->cat_ID == $cat->cat_ID) {
      echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
    }
  }
  echo "</ul>";
}
?>

<?php get_footer(); ?>

I am aware that the comments within the code give me some idea as to where to list the pages I want to hide however I am unsure as to how to do this. If anyone can help me it would be much appreciated.

Many Thanks.



via Chebli Mohamed

Embeded Youtube 360 video doesn't work in iOS Safari

Is there a way to embed a youtube video in a wordpress post that lets the 360 video work?

I made this test video, and it works everywhere I've tested so far except when I view it in iOS Safari.

The video plays, but the 360 environment doesn't function at all.

Thanks for any leads in figuring this out.



via Chebli Mohamed

WooCommerce: issue setting attributes with wp_set_object_terms

I need to set product's attributes via PHP code. According to other threads on StackOverflow, there's the method wp_set_object_terms. Unfortunately it is not working as it is supposed to do in my case:

For example, there is an attribute named "Hersteller", slug "hersteller". And there is a product, ID 593, with no "hersteller" attribute set.

I tried the following code to fill the attribute:

wp_set_object_terms(593, 'Alpina', 'pa_hersteller' , false);

When I'm attempting to display the attribute on the product page, there is no output, so it seems that the wp_set_object_terms process hasn't been successful. Following code produces an empty output:

$product->get_attribute('hersteller');

Furthermore, the attribute "hersteller" isn't even listed in the attribute list in the admin backend menue.

To debug the problem I've also tried the following code:

$attributes = get_post_meta( 593,  '_product_attributes' ); 
print_r($attributes);

resulting in the following output:

Array ( [0] => Array ( [pa_marken] => Array ( [name] => pa_marken [value] => [position] => 0 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_kategorien] => Array ( [name] => pa_kategorien [value] => [position] => 1 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_referenznummer] => Array ( [name] => pa_referenznummer [value] => [position] => 2 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_herstellergarantie] => Array ( [name] => pa_herstellergarantie [value] => [position] => 3 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_schlagwoerter] => Array ( [name] => pa_schlagwoerter [value] => [position] => 4 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) [pa_lieferzeit] => Array ( [name] => pa_lieferzeit [value] => [position] => 5 [is_visible] => 1 [is_variation] => 0 [is_taxonomy] => 1 ) ) )

Am I using the wp_set_object_terms method essentially wrong? I don't know what to do anymore now. May anyone here can help me? Thanks!



via Chebli Mohamed

User meta updating giving no value

So, I have the following to update the user meta:

<?php if ( is_user_logged_in() ) { ?>
    <?php echo '<input class="input" type="text" id="rhc_phone" name="rhc_phone" placeholder="Phone number" value="' .$current_user -> rh_phone. '"/>' ;?>                          
    <?php update_user_meta( $current_user->ID, 'rh_phone', esc_attr( $_POST['rhc_phone'] ) ); ?>            
<?php }else{ ?>
        <input class="input" type="text" id="rhc_phone" name="rhc_phone" placeholder="Phone number" value=""/>
<?php } ?>

However when I click submit, there is no value (not even the previous value).

What am I doing wrong?

Thanks!



via Chebli Mohamed

Woocommerce (Wordpress): How to get the Product when a customer buy a Product?

i just like to get the Product and Amount of the Product when a buyer buy a Product inside my Woocommerce-Plugin. So i can send this Action to the ERP Software to send some bill Information. Do you have some idea :) ? Thanks!



via Chebli Mohamed

How do I dynamically create a wordpress menu?

I have searched and searched and there is a post that shows that I can create pages and it has a spot to add the page to a menu. I would like to create a custom menu with parents and children. is this possible in word press.



via Chebli Mohamed

Remove and add actions in Wordpress using functions.php

I have edited some plugin files in wordpress but this is bad form - it stand up to updates. I'd like to make the changes using functions.php but I can't get it to work correctly.

The basics are that I want to remove the following actions:

add_action( 'woocommerce_before_my_account', array( $this, 'my_account_memberships' ) );

add_action( 'woocommerce_before_my_account', __CLASS__ . '::get_my_subscriptions_template' );

And in their place add the actions:

add_action( 'woocommerce_add_subscriptions_to_my_accoun', array( $this, 'my_account_memberships' ) );

add_action( 'woocommerce_add_subscriptions_to_my_account', __CLASS__ . '::get_my_subscriptions_template' );

I have tried adding the following (for both sets) to my functions.php but to no avail...

remove_action ( 'woocommerce_before_my_account', __CLASS__ . '::get_my_subscriptions_template' );

add_action( 'woocommerce_add_subscriptions_to_my_account', __CLASS__ . '::get_my_subscriptions_template' );

What am I doing wrong?



via Chebli Mohamed

how to show latest reviews on my homepage

I have a question and answer section on my website. I want to display the latest questions that people have posted in that section to appear on my homepage. An example would be how people display recent blog postings on the home page.

The questions and answer section is part of a wordpress plugin. Where as my website itself is a custom build.

Is there a simple code to grab the latest questions and post on the homepage?



via Chebli Mohamed

Featured image in WP Posts list (Backend)

Currently in Woocommerce i can see Product Thumbnail column in the posts (or products) lists in backend, see this example:

enter image description here

How i can get the thumbnail in column, but in Custom Posts Types? Without plugin

Excuse my english and in advance: Thanks :)



via Chebli Mohamed

How to decrease border height in ubermenu wordpress

Any idea how to decrease the height of this unnecessary border height? Ubermenu

I'm unable to decrease the height of that border under ubermenu control panel.

TOP ubermenu height

I tried to re-size the menu height using above entry, but it doesn't work for border height.



via Chebli Mohamed

WordPress - Get all of current page's queries information

Okay... so here is what I'm trying to do. Basically all of the components that make up any particular page on a Wordpress site, I need to be able to grab the query that WP is running to grab the data for that particular area of the given page. So, if we have page A, let's say it has a top navigation, main content section, and footer. Each of these three areas have content that is pulled from the database. I need a generic way to say on page X I want to know what queries have been ran to generate all of the content pulled from the database and displayed on the page.

I feel like the key is to properly use http://ift.tt/1xLY68I to get the data I need.

Any thoughts on how I could go about this?



via Chebli Mohamed

Background image wont show on the whole page

Hi i have a problem with my wordpress site - i used this css to change the background of page :

.page-id-689 #primary { background: url('http://ift.tt/1Z4CIYd') no-repeat center center !important;

-webkit-background-size: cover !important;

-moz-background-size: cover !important;

-o-background-size: cover !important;

background-size: cover !important;

min-height:100% !Important;

}


the problem is that the background wont show on the whole page ( Screenshot : http://ift.tt/1j0MDx4 ).

I already tried :

.page-id-287 #page_wrapper { height:100% !important; margin: 0px auto; }


html, body { height: 100% }


i also tried setting min-height to 100 % - wont work

!!! the problem is solved when i set the height to 1200px in #primary but it also causes huge problems in lower resolutions. Can someone help me with this ?



via Chebli Mohamed

How can I call a php / wordpress command from JavaScript?

I'm trying to create a lightbox effect for a self-made WordPress Theme. But I'm trying to include a WordPress page in the body through jQuery.

For example, in my js file.

    $('.button').Click(function(){

    $(body).append('`<div><?php get_template_part('content','thing'); ?></div>`');

});

I've tryed that and then my php file doesn't reproduce the php bit.

Thanks.



via Chebli Mohamed

Troubleshoot Codeigniter CLI stopped

I have been using the CLI interface to send out cron jobs from my codeigniter page. It worked fine until I updated Wordpress yesterday. I do not know how this effected Codeigniter but that is when the trouble started. I also installed cURL at about the same time. I am not sure if that could have made a difference.

SYMPTOMS: None of my codeigniter CLI scripts work. I have two scripts that send out email reminders, and another that synchronizes my database and none function.

ERRORS: I had some errors come up when I tried to run my scripts such as: Use of undefined constant DIR - assumed 'DIR'

This was never a problem before. But for now I change that to dirname(FILE) and that seemed to help. At least that error stopped.

Next another error notice appeared regarding code in my scripts that I was not getting before: "Can't use method return value in write context in . . ."

This error was in reference to this line of code:

if (!empty($this->get_available_hours($date, $provider_id))) {

I modified this to

$availabehours=$this->get_available_hours($date, $provider_id);
if (!empty($availabehours)) {

And the error stopped. But the script usually sends out email regarding availability and no email is sent.

Now I have no errors. I run the scripts and I get no results. If I purposefully mess with the code and do things wrong, I get the appropriate error messages. So, at some level it is reading the file.

I tried just running a simple "hello world file" as discribed here http://ift.tt/Y5erWB And nothing was returned.

I tried a simple email script that would send out an email without accessing my database and it did not send anything to me.

It appeares to me like something has caused my code to be interpreted in an older version of php. So I looked at the version currently running: PHP 5.2.17 (cli) (built: Feb 23 2012 10:42:34) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

This looks up to date.

MY QUESTION: What tests can I run to find out what is blocking things with my CLI? Any tips would be appreciated.



via Chebli Mohamed

Display Excerpts of Posts in Wordpress Blog

I have been searching for the answer to my problem and I continually come up with replacing

<?php the_content(); ?>

with

<?php the_excerpt(); ?>

in the index.php file. However, the theme we are using does not contain this line. Anyone have any insight? Here is the code in our index.php file:

    <?php $t =& peTheme(); ?>
<?php $content =& $t->content; ?>
<?php $meta =& $content->meta(); ?>
<?php get_header(); ?>

<section class="section-blog section-index" id="<?php $content->slug(); ?>">

    <div class="row">
        <div class="large-12 columns text-center">

        </div>
    </div>

    <div class="row blog-main">

        <div class="large-9 columns blog-left">

            <?php $t->content->loop(); ?>

        </div>

        <?php get_sidebar(); ?>

    </div>

</section>

<?php get_footer(); ?>



via Chebli Mohamed

Wordpress, add post to custom taxonomy's category

I am trying to add a post to a category under taxonomy cate. The code I am using is:

$user = get_user_by( 'email', $_POST['user'] );
$id = array(
    'post_title'    => $_POST['title'],
    'post_content'  => $_POST['content'],
    'post_date'     => date('Y-m-d H:i:s'),
    'post_author'   => $user->ID,
    'taxonomy' => ('cate'),
    'post_type'     => 'ad',
    'post_category' => array(425),
    'post_status'   => 'publish',
); 
 $user_id = wp_insert_post($id);
if ( ! is_wp_error( $user_id ) ) {
   $odgovor["success"] = 1;

}

The post is added but it's added under category 'uncategorized" and not under desired category ID. This system works properly when custom post type is not used. (In this case taxonomy 'cate')

Any ideas?



via Chebli Mohamed